πŸ”’ Bitwise Operator Calculator

Perform bitwise operations on binary numbers.

1100
1010

Operations

AND (&)

0
0000

OR (|)

0
0000

XOR (^)

0
0000

NOT (~) Num1

0
0000

Left Shift (<<)

0
0000

Right Shift (>>)

0
0000

Bitwise Operators

AND (&)

1 if both bits are 1

1 & 1 = 1
1 & 0 = 0
0 & 1 = 0
0 & 0 = 0

OR (|)

1 if at least one bit is 1

1 | 1 = 1
1 | 0 = 1
0 | 1 = 1
0 | 0 = 0

XOR (^)

1 if bits are different

1 ^ 1 = 0
1 ^ 0 = 1
0 ^ 1 = 1
0 ^ 0 = 0

NOT (~)

Inverts all bits

~1 = 0
~0 = 1

Left Shift (<<)

Shifts bits left, filling with 0

5 << 1 = 10
0101 β†’ 1010

Right Shift (>>)

Shifts bits right

10 >> 1 = 5
1010 β†’ 0101

Common Use Cases

  • Check if even: n & 1 === 0
  • Multiply by 2: n << 1
  • Divide by 2: n >> 1
  • Toggle bit: n ^ (1 << position)
  • Set bit: n | (1 << position)
  • Clear bit: n & ~(1 << position)