Bitwise Calculator — AND, OR, XOR, NOT, NAND, NOR, XNOR & Shifts
Calculate bitwise operations on two numbers — AND, OR, XOR, NOT, NAND, NOR, XNOR and left/right shifts — at 8, 16, 32 or 64-bit width. Enter values in decimal, hex (0x…) or binary (0b…) and see the result in binary, decimal and hex with a bit-by-bit aligned breakdown.
How to Use
- Enter operand A and operand B in decimal, hexadecimal (prefix 0x) or binary (prefix 0b).
- Pick a bit width (8, 16, 32 or 64) — results are masked to that many bits.
- Choose an operation: AND, OR, XOR, NOT, NAND, NOR, XNOR, or a left/right shift.
- Read the result in binary, decimal and hex, and inspect the bit-by-bit aligned rows below.
Bitwise operations, shown bit by bit
A bitwise operation works on the individual binary digits of a number rather than its decimal value. This calculator takes two operands — entered in decimal, hexadecimal (prefix 0x) or binary (prefix 0b) — and applies the logic gate you choose to each pair of bits, column by column. The result is reported simultaneously in binary, decimal and hexadecimal, and a monospace grid lines up A, B and the result so you can read off exactly which bits combined to produce each output bit. All arithmetic uses JavaScript BigInt, so even 64-bit values are exact, and everything runs locally in your browser.
Width, masking and shifts
Bit width matters because NOT, NAND, NOR and XNOR invert bits — and the answer depends on how many bits there are. The calculator masks every result to the selected width with (1 << width) − 1, so NOT 0x0F is 0xF0 at 8-bit but 0xFFF0 at 16-bit, matching an unsigned integer of that size. A left shift (A << B) moves bits toward the high end, multiplying by 2ᴮ, with bits that fall off the top discarded by the mask. A right shift (A >> B) moves bits toward the low end; a logical shift fills the top with zeros, while an arithmetic shift copies the sign bit so negative two’s-complement values stay negative — toggle the checkbox to compare them.
Quick reference
About the Bitwise Calculator — AND, OR, XOR, NOT, NAND, NOR, XNOR & Shifts
Use the Bitwise Calculator — AND, OR, XOR, NOT, NAND, NOR, XNOR & Shifts — a free, easy tool for everyday tasks. Nothing is uploaded, and you do not need an account. Calculate bitwise operations on two numbers — AND, OR, XOR, NOT, NAND, NOR, XNOR and left/right shifts — at 8, 16, 32 or 64-bit width. Enter values in decimal, hex (0x…) or binary (0b…) and see the result in binary, decimal and hex with a bit-by-bit aligned breakdown.
How it works
Put each value in its box and read the answer as you go. Because it recalculates live, you can play with the inputs to see how each one moves the result — handy for checking your own working or planning ahead. Everything happens on your device, so it is fast and private.
Want the deeper story? The Knowledge Base explains the ideas behind the tools in more detail.
Frequently Asked Questions
What input formats are accepted?
Each operand accepts decimal (e.g. 42), hexadecimal with a 0x prefix (e.g. 0x2A) and binary with a 0b prefix (e.g. 0b101010). The result is always shown in all three forms — binary, decimal and hexadecimal — at the selected width.
Why does NOT depend on the bit width?
NOT flips every bit, but “every bit” means every bit in the chosen width. NOT 0x0F is 0xF0 at 8-bit, but 0xFFF0 at 16-bit, because the high bits exist and get flipped too. The calculator masks the result to the width you pick so it matches how the value would behave in an unsigned integer of that size.
What is the difference between logical and arithmetic right shift?
A logical right shift always pads the vacated high bits with zeros. An arithmetic right shift copies the sign bit (the top bit), preserving the sign of a two’s-complement number, so a negative value stays negative. For unsigned bitmask work you usually want logical; for signed division-by-two you want arithmetic.
How are NAND, NOR and XNOR computed?
They are the complements of AND, OR and XOR. NAND = NOT (A AND B), NOR = NOT (A OR B), XNOR = NOT (A XOR B). Each result is masked to the selected bit width so the inverted high bits are accounted for.
Is anything sent to a server?
No. Every operation is computed in your browser with JavaScript BigInt arithmetic, so it handles 64-bit values exactly and nothing leaves your device.
How do I use the Bitwise Calculator — AND, OR, XOR, NOT, NAND, NOR, XNOR & Shifts?
Just type your numbers. The answer shows up right away — there is no button to press. Change anything and it updates by itself.
Do I need to install or sign up for anything?
Not at all — it runs in the browser with nothing to install and no account. After it loads once, it even works without an internet connection.
Is my information private?
Yes. Everything happens in your browser. Nothing you type is sent to a server or saved anywhere.
Common Use Cases
Bitmasks & flags
Set, clear and test flag bits with OR, AND and XOR when working with permission bits, feature flags or hardware registers.
Embedded & firmware
Verify register manipulations at an exact width — mask off bits, shift fields into position and check the resulting hex.
Learning digital logic
See AND/OR/XOR/NAND/NOR/XNOR truth values play out column-by-column across real numbers, not just single bits.
Networking
AND an address with a subnet mask, or shift to extract byte fields, while watching every bit line up.
Last updated: