Top "Bit-manipulation" questions

The manipulation of individual bits.

How do I programmatically return the max of two integers without using any comparison operators and without using if, else, etc?

How do I programmatically return the maximum of two integers without using any comparison operators and without using if, else, …

c bit-manipulation max obfuscation puzzle
Can XOR of two integers go out of bounds?

I had been studying the algorithm for finding lonely integers in an array, and here is the implementation: int arr[] = {10, 20, 30, 5, 20, 10, 30}; …

c++ c bit-manipulation integer-overflow bitwise-xor
Performance of integer and bitwise operations on GPU

Though GPUs are supposed for use with floating point data types, I'd be interested in how fast can GPU process …

performance opengl bit-manipulation glsl gpu
Determining a string has all unique characters without using additional data structures and without the lowercase characters assumption

This is one of the questions in the Cracking the Coding Interview book by Gayle Laakmann McDowell: Implement an algorithm …

java string algorithm bit-manipulation bitvector
Extract bit sequences of arbitrary length from byte[] array efficiently

I'm looking for the most efficient way of extracting (unsigned) bit sequences of arbitrary length (0 <= length <= 16) at arbitrary …

java bit-manipulation bits
How does the `test` instruction work?

If we have: test dword ptr [eax], 2000h je label1: Is there any value other than 0 in dword ptr [eax] …

assembly x86 bit-manipulation bitwise-operators instructions
From hexadecimal to one's complement in Python

Is there an easy way to produce a one's complement in python? For instance, if you take the hex value 0…

python bit-manipulation ones-complement
NASM: Count how many bits in a 32 Bit number are set to 1

I have a 32 Bit number and want to count know how many bits are 1. I'm thinking of this pseudocode: mov …

assembly x86 bit-manipulation nasm hammingweight
Correct usage of bitmask?

heyhey, just have a question about bitmasks. I think I know now what they are and where they can be …

java bit-manipulation bitwise-operators bit bitmask
Are enums the canonical way to implement bit flags?

Currently I'm using enums to represent a state in a little game experiment. I declare them like so: namespace State { …

c++ enums bit-manipulation bitflags std-bitset