Top "Bit-manipulation" questions

The manipulation of individual bits.

What does bitwise XOR (exclusive OR) mean?

I'm trying to understand the binary operators in C# or in general, in particular ^ - exclusive or. For example: Given …

math language-agnostic bit-manipulation operators xor
C/C++: Force Bit Field Order and Alignment

I read that the order of bit fields within a struct is platform specific. What about if I use different …

c++ c bit-manipulation endianness bit
What is CHAR_BIT?

Quoting the code for computing the integer absolute value (abs) without branching from http://graphics.stanford.edu/~seander/bithacks.html: …

c bit-manipulation
Why is the range of signed byte is from -128 to 127 (2's complement) and not from -127 to 127?

I read Why is the range of bytes -128 to 127 in Java? it says 128 is 10000000. Inverted, it's 01111111, and adding one …

math bit-manipulation computer-architecture twos-complement
Division without using '/'

Can anyone tell me an efficient approach to perform the division operation without using '/'. I can calculate the …

algorithm bit-manipulation division
How do uppercase and lowercase letters differ by only one bit?

I have found one example in Data and Communication Networking book written by Behrouza Forouzan regarding upper- and lowercase letters …

ascii bit-manipulation case-sensitive
What's the simplest way to test whether a number is a power of 2 in C++?

I need a function like this: // return true iff 'n' is a power of 2, e.g. // is_power_of_2(16) => …

c++ algorithm bit-manipulation
warning: left shift count >= width of type

I'm very new to dealing with bits and have got stuck on the following warning when compiling: 7: warning: left shift …

c bit-manipulation long-integer bit-shift
Should I use #define, enum or const?

In a C++ project I'm working on, I have a flag kind of value which can have four values. Those …

c++ enums bit-manipulation c-preprocessor
Catch and compute overflow during multiplication of two large integers

I am looking for an efficient (optionally standard, elegant and easy to implement) solution to multiply relatively large numbers, and …

c integer bit-manipulation multiplication integer-overflow