Bitwise Calculator

Perform bitwise AND, OR, XOR, NOT and bit shifts, with the result shown in decimal, binary and hex.

Numbers
Result
Runs locally in your browser

About the Bitwise Calculator

Bitwise operations work on the individual bits of a number and are the basis of flags, masks, permissions and low-level protocols. This calculator applies AND, OR, XOR, NOT, and left and right shifts. Enter the first number in the input pane and the second (for two-operand ops) in the toolbar, choosing whether the inputs are decimal, binary or hex. The result is shown in all three bases at once so you can see the bit pattern change.

AND, OR and XOR combine two numbers bit by bit; NOT inverts the bits of one number within a chosen width (8, 16 or 32 bits, since NOT depends on how many bits you consider); shifts move bits left or right by a number of places. Arbitrary-precision arithmetic means large operands work correctly.

For converting numbers between bases without an operation, use the Number Base Converter; for a colour's bits, the hex tools.

How to use

  1. Enter the first number in the pane and choose the input base.
  2. Choose the operation and the second operand or shift amount.
  3. Read the result in decimal, binary and hex.

Common questions

Why does NOT need a bit width?
Inverting bits depends on how many bits represent the number. NOT of 5 differs in 8-bit and 32-bit widths, so you choose one.
Can I use hex operands?
Yes, set the input base to hex and enter both numbers in hex.
Does it do two's complement negatives?
NOT works within the chosen width. General negative handling uses arbitrary-precision signed values.