Developer Tools
Bitwise calculator.
AND, OR, XOR, NOT and bit shifts on 8, 16, 32 or 64-bit values. Enter decimal, hex, binary or octal, see the signed and unsigned result and the bits lined up. Runs in your browser.
Input
Result
Enter values, then press Calculate.
How it works
- Width: A and B are read as a bit pattern of the chosen width. A value is accepted from -2n-1 to 2n-1 (8-bit: -128 to 255); negative inputs become their two's complement pattern, so -1 and 255 are the same 8 bits. The signed view of a result is two's complement.
- &, |, ^: AND is 1 only where both bits are 1, OR is 1 where either is, XOR is 1 where they differ.
1100 & 1010 = 1000,1100 | 1010 = 1110,1100 ^ 1010 = 0110. - ~ (NOT): flips every bit within the width. At 8 bits, ~5 is 250 unsigned and -6 signed.
- << (left shift): moves bits toward the top and fills with 0. Bits shifted past the top are discarded.
- >> (arithmetic right shift): moves bits down and copies the sign bit into the gap, so negative numbers stay negative. >>> (logical right shift): fills with 0 instead.
- Shift count: a whole number from 0 to width-1. JavaScript itself only applies these operators to 32-bit integers and takes the count modulo 32; this tool applies the same definitions at the width you choose and rejects counts outside the range instead of wrapping them.
- Precision: uses BigInt, so 64-bit values are exact. Nothing is sent anywhere.
Sources: MDN, JavaScript operators (see <<, >>, >>>); Wikipedia, Bitwise operation. Related: Two's Complement Calculator, IEEE 754 Float Converter, Binary Converter.
Worked example at 8 bits
A = 240 (1111 0000, hex F0) and B = 60 (0011 1100, hex 3C). Results come from running this page’s calculator code on 2026-10-26.
| Operation | Input bits | Result bits | Unsigned / signed |
|---|---|---|---|
| A & B | 1111 0000 and 0011 1100 | 0011 0000 | 48 / 48 |
| A | B | 1111 0000 and 0011 1100 | 1111 1100 | 252 / -4 |
| A ^ B | 1111 0000 and 0011 1100 | 1100 1100 | 204 / -52 |
| ~5 | 0000 0101 | 1111 1010 | 250 / -6 |
| 13 << 2 | 0000 1101 | 0011 0100 | 52 / 52 |
| −16 >> 2 | 1111 0000 | 1111 1100 | 252 / -4 |
| −16 >>> 2 | 1111 0000 | 0011 1100 | 60 / 60 |
Sources and as-of date
As of 2026-10-26. Operator semantics follow the MDN reference for JavaScript, applied here at the width you pick.
- MDN: Bitwise AND (&) (retrieved 2026-10-26): AND on integer operands.
- MDN: Bitwise OR (|) (retrieved 2026-10-26): OR on integer operands.
- MDN: Bitwise XOR (^) (retrieved 2026-10-26): XOR on integer operands.
- MDN: Bitwise NOT (~) (retrieved 2026-10-26): NOT flips every bit.
- MDN: Left shift (<<) (retrieved 2026-10-26): bits move up and zeros fill the gap.
- MDN: Right shift (>>) (retrieved 2026-10-26): the sign bit is copied into the gap.
- MDN: Unsigned right shift (>>>) (retrieved 2026-10-26): zeros fill the gap.
- MDN: BigInt (retrieved 2026-10-26): exact whole-number arithmetic with no rounding, which is why very long values convert without error.
Frequently asked questions
What is the difference between >> and >>>?
>> copies the sign bit into the gap, so negative numbers stay negative: at 8 bits, −16 (1111 0000) shifted right by 2 is -4 (1111 1100). >>> fills with zeros, so the same input gives 60 (0011 1100).
Why is ~5 equal to −6?
NOT flips every bit inside the chosen width. At 8 bits 5 is 0000 0101, so ~5 is 1111 1010, which is 250 unsigned and -6 as a two’s complement signed value.
Why does JavaScript give different answers for large values?
JavaScript applies bitwise operators to 32-bit integers and takes shift counts modulo 32. This tool uses BigInt at 8, 16, 32 or 64 bits, so a 64-bit mask stays exact and an out-of-range shift count is rejected instead of wrapped.
How do I test whether one bit is set?
AND the value with a mask that has only that bit. 60 & 4 gives 4, which is not zero, so bit 2 of 0011 1100 is set.