Top "Bit-manipulation" questions

The manipulation of individual bits.

Why is squaring a number faster than multiplying two random numbers?

Multiplying two binary numbers takes n^2 time, yet squaring a number can be done more efficiently somehow. (with n being …

algorithm math bit-manipulation discrete-mathematics
Bitwise operators and "endianness"

Does endianness matter at all with the bitwise operations? Either logical or shifting? I'm working on homework with regard to …

c bit-manipulation endianness bit-shift
Understanding the bitwise AND Operator

I have been reading about bit operators in Objective-C in Kochan's book, "Programming in Objective-C". I am VERY confused about …

objective-c operators bit-manipulation bitwise-operators
Efficiently find binary strings with low Hamming distance in large set

Problem: Given a large (~100 million) list of unsigned 32-bit integers, an unsigned 32-bit integer input value, and a maximum Hamming …

algorithm bit-manipulation bitwise-operators hamming-distance
How does XOR variable swapping work?

Can someone explain to me how XOR swapping of two variables with no temp variable works? void xorSwap (int *x, …

language-agnostic bit-manipulation xor
How to compute log base 2 using bitwise operators?

I need to compute the log base 2 of a number in C but I cannot use the math library. The …

c bit-manipulation logarithm binary-log
Doing a bitwise operation on bytes

I got two objects, a and b, each containing a single byte in a bytes object. I am trying to …

python python-3.x bit-manipulation bitwise-and
bitwise AND in Javascript with a 64 bit integer

I am looking for a way of performing a bitwise AND on a 64 bit integer in JavaScript. JavaScript will cast …

javascript 64-bit integer bit-manipulation
Extracting bits with a single multiplication

I saw an interesting technique used in an answer to another question, and would like to understand it a little …

c multiplication bit-manipulation
What does (x ^ 0x1) != 0 mean?

I came across the following code snippet if( 0 != ( x ^ 0x1 ) ) encode( x, m ); What does x ^ 0x1 mean? Is this …

c++ c bit-manipulation bitmask