Developer tools

Bitwise calculator

Run AND, OR, XOR, shifts and rotates on fixed-width integers in decimal, hex and binary.

Bitwise calculator
Esc to restore

Your inputs

Decimal, 0x hex, 0b binary or 0o octal. Underscores are allowed. Negative decimals wrap as two’s complement.

Results update as you type. Larger files run when you press Update result.

Your result

Your result will appear here.

More actions

Your inputs stay in this browser. Nothing is uploaded, and nothing is saved unless you choose “Save result”.

A clear answer. Here’s how.

Values are held as fixed-width two’s complement integers using exact BigInt arithmetic, so 64-bit results are precise. Signed values wrap into the chosen width before the operation. Logical shifts fill with zeros, arithmetic shifts copy the sign bit, and rotates move bits around the edge. Shift and rotate counts run from 0 to the width. The signed output reads the top bit as the sign.

See a worked example

Worked example

A fixed demonstration, separate from the values you enter above.

First value
0xCA
Operation
XOR (a ^ b)
Second value or shift count
0b00001111
Bit width
8 bits

Example result

Result (unsigned)
197
Result (signed, two’s complement)
-59
Result (hex)
0xC5
Result (binary)
1100 0101
Result (octal)
0o305
Bits set in result
4
First value (binary)
1100 1010
Second value (binary)
0000 1111

Values are fixed-width 8-bit two’s complement integers. Negative decimal inputs wrap into that width; rotate and shift counts come from the second value.