Bitwise Calculator
100% private — runs on your device, never uploaded. Works offline once loaded.
Perform bitwise AND, OR, XOR, NOT and left/right shifts on two integers entered in decimal, hexadecimal or binary, and see the result in decimal, hex, binary and octal with the full 32-bit pattern.
What bitwise operations do
Bitwise operators work on the individual binary digits of an integer rather than its numeric value. AND keeps a bit only when it is set in both operands, OR sets a bit when it is set in either, XOR sets a bit when the two differ, and NOT flips every bit. Shifts slide the whole bit pattern left or right by a number of positions. These operations are the building blocks of flags, permissions, colour packing, hashing and low-level protocol code.
This calculator lets you enter two integers in whatever base is convenient, apply an operation, and immediately see what happens at the bit level — which is far easier to reason about than doing the arithmetic in your head.
32-bit signed semantics
The tool mirrors how JavaScript and C treat integers in bitwise expressions: values are coerced into a signed 32-bit two's-complement range before the operation, and the result is a signed 32-bit integer. That is why NOT 0 is -1 (all bits set) as a signed number, but 4294967295 when you read the same bit pattern as unsigned.
To make that explicit the result panel shows four things: the signed decimal result, the unsigned decimal value of the same bits, and the hexadecimal and octal forms of the unsigned pattern. The binary field below shows all 32 bits grouped into nibbles so you can trace exactly which bits changed.
- AND (&), OR (|), XOR (^): combine two operands bit by bit.
- NOT (~): unary — inverts every bit of operand A only.
- Left shift (<<) and right shift (>>): move bits by B positions, B taken modulo 32.
Reading the output
Each result base answers a different question. Hexadecimal is the compact form you will see in memory dumps and colour codes; binary makes individual flag bits obvious; octal maps neatly onto Unix permission triplets; and the signed/unsigned decimal pair tells you how the same 32 bits are interpreted depending on the type.
A worked example: 0xFF AND 0x0F is 0x0F (15) because only the low four bits are set in both operands. 1 << 31 is -2147483648 as a signed int but 2147483648 unsigned, because shifting into the top bit sets the sign bit.
Caveats
JavaScript's bitwise operators — which this tool uses — only work on 32 bits, so values above 2^31-1 wrap around into negative territory and anything beyond 32 bits is truncated. If you need 64-bit or arbitrary-width bit math, use a language with BigInt or fixed-width integer types instead.
Shift amounts are always reduced modulo 32, so a shift of 33 behaves like a shift of 1. This matches the ECMAScript specification and most CPU shift instructions, but it is a common source of surprise, so the tool notes it explicitly.
Frequently asked questions
Why does NOT of a positive number look negative?
NOT flips every bit, which sets the top (sign) bit, so the signed 32-bit interpretation is negative. The unsigned decimal and the raw binary pattern shown alongside make the real bit pattern clear.
What is the difference between the signed and unsigned decimal results?
They are the same 32 bits read two ways. Signed uses two's-complement so the highest bit means negative; unsigned treats all 32 bits as magnitude, giving a value from 0 to 4294967295.
How do I enter a hexadecimal or binary number?
Prefix it: 0xFF for hex, 0b1010 for binary, 0o17 for octal, or a plain number for decimal. Alternatively set the Input base dropdown to force one base for both operands.
Is right shift arithmetic or logical?
It is arithmetic (>>), meaning the sign bit is copied into the vacated high bits, so -8 >> 1 is -4. This matches signed right shift in C and JavaScript.
Does operand B matter for NOT?
No. NOT is a unary operation, so only operand A is used and the B field is hidden while NOT is selected.
Can it handle numbers larger than 32 bits?
No. Like JavaScript's bitwise operators, values are truncated to 32 bits. For wider math you would need a 64-bit or BigInt-based tool.
Advertisement