A bitwise calculator lets you apply operations like AND, OR, XOR, NOT, and shifts to numbers and see the result instantly in decimal, hex, binary, and octal. If you have ever wondered why 12 & 10 equals 8, this is the fastest way to find out. Here is what each operation does and how to run one in your browser.
What bitwise operations do
Bitwise operations work on the individual bits of a number rather than its decimal value. There are six you will use most:
- AND (&): a bit is 1 only if both inputs have a 1 there. Used to mask or test bits.
- OR (|): a bit is 1 if either input has a 1. Used to set bits.
- XOR (^): a bit is 1 if the inputs differ. Used to toggle bits.
- NOT (~): flips every bit. With two’s complement,
~nequals-(n + 1). - Left shift (<<): moves bits left, filling with zeros. Shifting left by n multiplies by 2 to the power n.
- Right shift (>>): moves bits right, dividing by powers of two.
A worked example: 12 & 10
Take 12 & 10. In binary, 12 is 1100 and 10 is 1010. AND keeps a 1 only where both have a 1:
1100 (12)
& 1010 (10)
----
1000 (8)
The result is 8. A right shift like 12 >> 1 gives 6, and a left shift 12 << 1 gives 24, because shifting left once multiplies by 2.
Where bitwise math is used
These operations are not just academic. They power a lot of everyday code:
- Flags and bitmasks: pack many on/off settings into one integer. OR sets a flag, AND tests it, XOR toggles it.
- Permissions: file modes like
755and capability systems use bits to represent read, write, and execute rights. - Fast math: shifting is a cheap way to multiply or divide by powers of two.
Two’s complement is what makes negative numbers and NOT behave consistently across all of this.
Run an operation in three steps
- Open the Bitwise Calculator and enter your two numbers.
- Pick the operation: AND, OR, XOR, NOT, left shift, or right shift.
- Read the result in decimal, hex, binary, and octal, and check the bit-pattern visualizer to see exactly which bits changed.
Everything runs in your browser, so your numbers never leave your device. The Bitwise Calculator is handy whenever you need to verify a mask or debug a shift without firing up a REPL.
Related tools
- Working with structured data? Try the JSON Formatter & Validator to clean up and check API payloads.
- Encoding binary data as text? Use Base64 Encode / Decode.
- Building query strings or URLs? Reach for URL Encode / Decode.
Enter two numbers, pick an operation, and watch the bits line up.