Top "Bit-manipulation" questions

The manipulation of individual bits.

How to define and work with an array of bits in C?

I want to create a very large array on which I write '0's and '1's. I'm trying to …

c arrays multidimensional-array bit-manipulation bitarray
Find most significant bit (left-most) that is set in a bit array

I have a bit array implementation where the 0th index is the MSB of the first byte in an array, …

c bit-manipulation 32-bit
How to extract specific bits from a number in C?

I need to extract specific part (no of bits) of a short data type in C. For Example I have …

c bit-manipulation bit bit-shift
Position of least significant bit that is set

I am looking for an efficient way to determine the position of the least significant bit that is set in …

c++ c optimization bit-manipulation
Check value of least significant bit (LSB) and most significant bit (MSB) in C/C++

I need to check the value of the least significant bit (LSB) and most significant bit (MSB) of an integer …

c++ c integer bit-manipulation bit
bit-wise operation unary ~ (invert)

I'm a little confused by the ~ operator. Code goes below: a = 1 ~a #-2 b = 15 ~b #-16 How does ~ do work? …

python bit-manipulation
How to perform multiplication, using bitwise operators?

I am working through a problem which i was able to solve, all but for the last piece - i …

bit-manipulation multiplication
How does this bitwise operation check for a power of 2?

I'm looking at some code which should be trivial -- but my math is failing me miserably here. Here's a …

c math bit-manipulation
Set specific bit in byte

I'm trying to set bits in Java byte variable. It does provide propper methods like .setBit(i). Does anybody know …

java byte bit-manipulation
Explain this snippet which finds the maximum of two integers without using if-else or any other comparison operator?

Find the maximum of two numbers. You should not use if-else or any other comparison operator. I found this question …

c algorithm math bit-manipulation max