Top "Bit-manipulation" questions

The manipulation of individual bits.

Using Bitwise operators on flags

I have four flags Current = 0x1 Past = 0x2 Future = 0x4 All = 0x7 Say I receive the two flags Past and …

c# .net bit-manipulation bit-fields
Compute fast log base 2 ceiling

What is a fast way to compute the (long int) ceiling(log_2(i)), where the input and output are 64-bit …

c optimization math 64-bit bit-manipulation
Bitwise Multiply and Add in Java

I have the methods that do both the multiplication and addition, but I'm just not able to get my head …

java bit-manipulation bitwise-operators multiplication addition
Left bit shifting 255 (as a byte)

Can anyone explain why the following doesn't compile? byte b = 255 << 1 The error: Constant value '510' cannot be …

c# bit-manipulation bit-shift
Java: right shift on negative number

I am very confused on right shift operation on negative number, here is the code. int n = -15; System.out.…

java bit-manipulation bitwise-operators bit-shift negative-number
Is there an elegant way to Invert a Bit value in an SQL insert Statement?

I'm converting some data in SQL Server: INSERT INTO MYTABLE (AllowEdit) (Select PreventEdit from SOURCETABLE) so I need to inverse …

sql sql-server bit-manipulation
Is shifting bits faster than multiplying and dividing in Java? .NET?

Shifting bits left and right is apparently faster than multiplication and division operations on most, maybe even all, CPUs if …

c# java .net optimization bit-manipulation
Is & faster than % when checking for odd numbers?

To check for odd and even integer, is the lowest bit checking more efficient than using the modulo? >>&…

python performance bit-manipulation modulo
What is lower and higher bits?

Can anyone tell me what is lower and higher bits?. How to identify a higher and lower bit?. Below is …

binary bit-manipulation bit
How to create a byte out of 8 bool values (and vice versa)?

I have 8 bool variables, and I want to "merge" them into a byte. Is there an easy/preferred method to …

c++ boolean bit-manipulation bit-packing