Bitwise calculator
Run AND, OR, XOR, shifts and rotates on fixed-width integers in decimal, hex and binary.
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.