Skip to main content
Visual Playground

Bitwise Operations & Masking

Flipping bits, shifting masks, and learning visual binary algorithms.

Register Size:
Signed Mode:
Operand A
DEC:
HEX:
2^70128
2^6164
2^5032
2^4116
2^318
2^204
2^112
2^001
Operator
Operand B
DEC:
HEX:
2^70128
2^6064
2^5132
2^4116
2^318
2^214
2^102
2^001
Step 0Total -1
Calculation Trace Output
A:
01011010
(90)
B (&):
00111100
(60)
Result:
00000000
(0)
Useful Bit Hacks & Recipes
Check Odd/Even Parityx & 1

Determines if a number is odd or even by inspecting the least significant bit (LSB).

Clear Lowest Set Bitx & (x - 1)

Turns off the rightmost active bit (the lowest 1 bit) of a binary register.

Isolate Lowest Set Bitx & -x

Extracts only the rightmost set bit, zeroing out all other bits.

Check Power of 2(x > 0) && (x & (x - 1)) == 0

Quickly checks if a positive number is an exact power of 2.

XOR Swap TrickA ^ B

Swaps two registers without using a third temporary variable.