Unconditional code
Bit Twiddling Hacks
- Merge bits from two values according to a mask
- Conditionally set or clear bits without branching
- Conditionally negate a value without branching
- Detect if two integers have opposite signs
- Compute the integer absolute value (abs) without branching
- Compute the minimum (min) or maximum (max) of two integers without branching
- Determining if an integer is a power of 2
The Aggregate Magic Algorithms
see also
- Mel’s Hack – The Missing Bits - a finite loop with no exit condition.
Written on March 2, 2020, Last update on May 29, 2023
bits
float
c++