Top "Bit-manipulation" questions

The manipulation of individual bits.

Fast computing of log2 for 64-bit integers

A great programming resource, Bit Twiddling Hacks, proposes (here) the following method to compute log2 of a 32-bit integer: #define …

c 64-bit bit-manipulation 32bit-64bit lookup
How to create mask with least significat bits set to 1 in C

Can someone please explain this function to me? A mask with the least significant n bits set to 1. Ex: n = 6 …

c bit-manipulation bitmask
How can I detect integer overflow on 32 bits int?

I know such topic was asked several times, but my question is about overflow on full 32 bits of int. For …

java integer bit-manipulation integer-overflow integer-arithmetic
How do I check, if bitmask contains bit?

I don't quite understand this whole bitmask concept. Let's say I have a mask: var bitMask = 8 | 524288; I undestand that this …

c# bit-manipulation bitmask
javascript trunc() function

I want to truncate a number in javascript, that means to cut away the decimal part: trunc ( 2.6 ) == 2 trunc (-2.6 ) == -2 …

javascript bit-manipulation bitwise-operators
Have you ever had to use bit shifting in real projects?

Have you ever had to use bit shifting in real programming projects? Most (if not all) high level languages have …

bit-manipulation bit-shift
What USEFUL bitwise operator code tricks should a developer know about?

I must say I have never had cause to use bitwise operators, but I am sure there are some operations …

language-agnostic bit-manipulation bit
Should I bit-shift to divide by 2 in Java?

Possible Duplicates: Is shifting bits faster than multiplying and dividing in Java? .NET? Quick Java Optimization Question Many years ago …

java performance bit-manipulation division bit-shift
Two elements in array whose xor is maximum

Given an array of integers ,You have to find two elements whose XOR is maximum. There is naive approach --just …

arrays algorithm bit-manipulation xor
Performance wise, how fast are Bitwise Operators vs. Normal Modulus?

Does using bitwise operations in normal flow or conditional statements like for, if, and so on increase overall performance and …

c++ bit-manipulation bitwise-operators