Skip to main content
DevTools24

Bitwise Calculator

Perform bitwise operations (AND, OR, XOR, NOT, shifts) and visualize binary representations.

= 42 (decimal)
= 15 (decimal)
A:0 0 1 0 1 0 1 0
B:0 0 0 0 1 1 1 1
AND(&)
Both bits must be 1
Dec:10
Hex:0xA
Bin:00001010
OR(|)
Either bit can be 1
Dec:47
Hex:0x2F
Bin:00101111
XOR(^)
Bits must differ
Dec:37
Hex:0x25
Bin:00100101
NOT A(~)
Flip all bits of A
Dec:-43
Hex:0xFFFFFFD5
Bin:11111111111111111111111111010101
NOT B(~)
Flip all bits of B
Dec:-16
Hex:0xFFFFFFF0
Bin:11111111111111111111111111110000
Left Shift(<<)
Shift A left by 2
Dec:168
Hex:0xA8
Bin:10101000
Right Shift(>>)
Shift A right by 2
Dec:10
Hex:0xA
Bin:00001010
Zero-fill Right(>>>)
Unsigned right shift A by 2
Dec:10
Hex:0xA
Bin:00001010

Bitwise Operations - Technical Details

Bitwise operations work on individual bits of integers. AND (&) returns 1 if both bits are 1. OR (|) returns 1 if either bit is 1. XOR (^) returns 1 if bits differ. NOT (~) flips all bits.

Command-line Alternative

// Bitwise operations\n5 & 3  = 1     // AND: 101 & 011 = 001\n5 | 3  = 7     // OR:  101 | 011 = 111\n5 ^ 3  = 6     // XOR: 101 ^ 011 = 110\n~5     = -6    // NOT: inverts all bits