Bitwise Operations Calculator
Perform bitwise AND, OR, XOR, NOT, and shift operations on integer values. See each result in decimal, binary, and hexadecimal to understand exactly how individual bits change.
Calculate bitwise operations
Enter integers in decimal, binary, or hexadecimal notation. Choose an operation and calculate the result using 32-bit integer semantics.
0b binary, and 0x hexadecimal.Bitwise operators explained
| Operation | Symbol | How it works |
|---|---|---|
| AND | & | A result bit is 1 only if both corresponding input bits are 1. |
| OR | | | A result bit is 1 if either corresponding input bit is 1. |
| XOR | ^ | A result bit is 1 when the corresponding input bits differ. |
| NOT | ~ | Inverts each bit of the 32-bit signed integer representation, then applies the selected display mask. |
| Left shift | << | Moves bits to the left. Bits shifted beyond the 32-bit boundary are discarded. |
| Signed right shift | >> | Moves bits right while preserving the sign bit. |
| Unsigned right shift | >>> | Moves bits right and fills the left side with zeros. |
How to use the bitwise calculator
- Enter the first integer in decimal, binary with a
0bprefix, or hexadecimal with a0xprefix. - Enter a second integer or shift amount when required by the selected operation.
- Choose AND, OR, XOR, NOT, or one of the shift operations.
- Select a display width of 8, 16, or 32 bits.
- Click Calculate to view the result in several number formats.
Example: bitwise AND
Calculate 12 AND 10:
| Number | Decimal | Binary (4-bit example) |
|---|---|---|
| A | 12 | 1100 |
| B | 10 | 1010 |
| A AND B | 8 | 1000 |
Only the third bit from the right is set in both inputs, so the result is 8.
Frequently asked questions
What is a bitwise operation?
A bitwise operation works on the individual binary digits of integer values rather than treating each input as a single true/false value.
What is the difference between bitwise XOR and OR?
OR produces 1 when either input bit is 1, including when both are 1. XOR produces 1 only when the input bits differ.
Why can bitwise NOT produce a negative number?
In JavaScript, bitwise NOT operates on a signed 32-bit integer. The displayed signed result may be negative. This calculator also shows its unsigned representation and a width-limited binary display.
What is a shift operation?
A shift moves binary digits left or right. Left shifts can multiply an integer by powers of two when overflow is not involved. Right shifts move bits toward the least significant position.
Does this calculator use 8-bit, 16-bit or 32-bit arithmetic?
Bitwise arithmetic uses JavaScript's 32-bit integer behavior. The width selector controls the displayed binary length and the mask used for the NOT result.