Interactive Computer Science Tutoring

Learn programming concepts interactively

AHA Schools Logo

C Bitwise Operations

Master bit manipulation and binary operations in C

Bitwise Operations
Explore different bitwise operators
Interactive Bit Calculator
Manipulate bits by clicking them
Operand A (click bits to toggle)
Dec: 170Hex: 0xAA
1
0
1
0
1
0
1
0
7
6
5
4
3
2
1
0
Operand B (click bits to toggle)
Dec: 85Hex: 0x55
0
1
0
1
0
1
0
1
7
6
5
4
3
2
1
0
&
Result
Dec: 0Hex: 0x00
0
0
0
0
0
0
0
0
7
6
5
4
3
2
1
0
Bit-by-Bit Animation
Watch the operation process each bit
Operation Logic
Truth Table:
ABResult
000
010
100
111
Bitwise Challenge
Test your bit manipulation knowledge
What is the result of 12 & 7 in binary?
Bitwise Operation Code
Interactive C code with memory visualization
Bitwise Operation Log0/5
Recent operations with timestamps

No operations yet

Start by adding or modifying elements

Common Bit Patterns
🎯 Bit Masking
value & 0x0F // Keep only lower 4 bits
🏳️ Flag Setting
flags |= FLAG_ENABLED // Set flag
🔄 Bit Toggling
state ^= 0x01 // Toggle lowest bit
Real-World Applications
Hardware Control
Setting specific pins on microcontrollers
Flags and Options
Compact storage of boolean states
Fast Math
Multiply/divide by powers of 2 with shifts
Cryptography
XOR operations in encryption algorithms
Performance Tips
Use shifts for powers of 2
x << 1 is faster than x * 2
Bit fields for compact storage
Pack multiple flags into single integers
AND for even/odd check
if (x & 1) // Check if odd