About the Bitwise Calculator
Bitwise operations work on the individual bits of numbers and are everywhere in low-level programming, networking, graphics and hardware. This calculator applies AND, OR, XOR and their inverted forms NAND, NOR and XNOR to two numbers, flips all the bits of one number with NOT, or shifts the bits left or right. You can enter numbers in decimal, hexadecimal with a 0x prefix, binary with 0b or octal with 0o, and choose the width in bits. Results are shown in decimal, hex and as a grouped binary string, with the inputs lined up so you can see exactly what happened, bit by bit.
Updated October 2026
How to use the Bitwise Calculator
- 1Choose the operation and the number of bits.
- 2Enter A, and B if the operation needs it. Use decimal, 0x hex, 0b binary or 0o octal.
- 3Read the result in decimal, with the signed value and the hex form.
- 4Check the binary rows to follow the operation bit by bit.
- 5Copy the result.
A worked example
Take A = 202 (11001010) and B = 108 (01101100) in 8 bits. AND gives 01001000, which is 72. OR gives 11101110 (238). XOR gives 10100110 (166). The inverted forms follow: NAND is 10110111 (183), NOR is 00010001 (17) and XNOR is 01011001 (89). The binary rows in the result make each step easy to check.
Everyday uses
- Masks: AND with 0xFF keeps only the low byte of a value.
- Flags: OR sets a bit, AND with a NOT mask clears it, XOR toggles it.
- Networking: AND an IP address with the subnet mask to find the network.
- Graphics: pack and unpack colour channels in one integer.
- Hashing and checksums: XOR is the building block.
Tips
Match the width to your data type, such as 8 bits for a byte, 32 for an int and 64 for a long. Remember that JavaScript bitwise operators work on 32-bit signed numbers, so results for larger widths here may differ from what a quick console test shows. Use hex input for masks, because each hex digit is exactly four bits.
Related tools
The Binary Calculator does arithmetic on binary numbers, the Number Base Converter moves between bases, the Gray Code and BCD Converter handles special encodings and the IP Subnet Calculator applies masks to addresses.
Features
- AND, OR, XOR, NAND, NOR, XNOR, NOT
- Shift left and shift right
- 8, 16, 32 and 64-bit widths
- Decimal, hex, binary and octal input
- Signed (two's complement) value shown
- Large numbers handled exactly
Frequently asked questions
What does bitwise AND do?
It compares two numbers bit by bit and sets a bit to 1 only if both numbers have a 1 in that position. For example, 202 AND 108 is 72, because only the bits that are 1 in both numbers stay 1.
What is the difference between OR and XOR?
OR sets a bit to 1 if either number has a 1 there. XOR (exclusive or) sets it to 1 only if the bits are different. XOR is useful for toggling bits and in simple checksums and encryption.
What do NAND, NOR and XNOR mean?
They are the AND, OR and XOR results with every bit flipped. In digital logic, NAND and NOR are called universal gates because any circuit can be built from either one.
What does NOT do?
NOT flips every bit of the number within the chosen width. For an 8-bit number, NOT of 202 (11001010) is 53 (00110101). Because the width matters, NOT of 0 is 255 in 8 bits and 4,294,967,295 in 32 bits.
How do bit shifts work?
Shifting left by n bits multiplies by 2 to the power n, discarding bits that fall off the top. Shifting right divides by 2 to the power n, rounding down. The calculator fills with zeros from the left when shifting right.
How are negative numbers handled?
Negative inputs are converted to two's complement in the chosen width, the way computers store them. For example, −1 in 8 bits is 11111111, which is 255 unsigned. The signed value in the result shows how the answer reads as a signed number.