Bitwise Calculator
Compute AND, OR, XOR, NOT, and bit shifts on integers, live as you type.
Operates on 32-bit signed integers, matching JavaScript's own bitwise operators. Updates live. Runs entirely in your browser.
Need the opposite? XOR Calculator
What is Bitwise Calculator?
Enter one or two integers, pick an operation (AND, OR, XOR, NOT, left/right shift), and see the result instantly in both decimal and binary. It uses JavaScript's own 32-bit bitwise operators, the same ones your code would use. Useful for sanity-checking a bitmask, flag combination, or shift operation before it goes into code, or for working out by hand what a line like `flags & 0x08` or `value >> 2` actually evaluates to. Everything computes live in your browser as you type, with no size limit beyond the 32-bit range the operations themselves are defined over.
AND / OR / XOR Truth Table
| A, B | AND | OR | XOR |
|---|---|
| 0, 0 | 0 | 0 | 0 |
| 0, 1 | 0 | 1 | 1 |
| 1, 0 | 0 | 1 | 1 |
| 1, 1 | 1 | 1 | 0 |
How to Use the Bitwise Calculator
- 1
Enter One or Two Integers: Type the values you want to operate on.
- 2
Choose an Operation: Pick AND, OR, XOR, NOT, or a shift.
- 3
Read the Result Instantly: The decimal and binary result appears automatically.
How AND, OR, and XOR Work Bit by Bit
Each operator compares two numbers one bit position at a time. AND (&) produces a 1 only when both bits are 1. OR (|) produces a 1 when at least one bit is 1. XOR (^) produces a 1 only when the two bits differ. Worked example with 12 (binary 1100) and 10 (binary 1010): 12 & 10 = 8 (1000): only the third bit is 1 in both. 12 | 10 = 14 (1110): every bit that's 1 in either number. 12 ^ 10 = 6 (0110): the bits where 12 and 10 differ. NOT (~) flips every bit, including the sign bit, which is why ~12 gives -13 rather than a positive number. This is two's-complement behavior, the same as `~x` in JavaScript or C.
Shift Operators
Left shift (<<): Moves every bit left by the given amount, filling with 0s on the right. It's equivalent to multiplying by 2 for each position shifted: 4 << 2 = 16 (4 × 2²).
Right shift (>>): Moves bits right, filling from the left with copies of the sign bit, so negative numbers stay negative: -8 >> 1 = -4.
Unsigned right shift (>>>): Always fills with 0s regardless of sign, which is why it turns a negative number into a large positive one: -8 >>> 1 = 2147483644.
Frequently Asked Questions
Common questions about Bitwise Calculator.