Bitwise Calculator

AND, OR, XOR, NOT, Left/Right shift — binary visualization

A

Perform AND, OR, XOR, and other bitwise operations

DEC: 60HEX: 0x3C
00111100
B

Perform AND, OR, XOR, and other bitwise operations

DEC: 13HEX: 0x0D
00001101
A & B =

Perform AND, OR, XOR, and other bitwise operations

DEC: 12HEX: 0x0C
00001100

AND: Both bits must be 1

About the Bitwise Calculator

This bitwise calculator performs AND, OR, XOR, NOT and left and right shifts, showing the binary, decimal and hexadecimal form of every operand and result. Seeing the bits line up is what makes flag and mask work checkable.

A bitwise calculator is for the operations that treat a number as a row of bits rather than a quantity: combining permission flags with OR, testing one with AND, toggling with XOR, and multiplying or dividing by powers of two with shifts.

The reason to use a tool rather than reason it out is visibility. Every operand and result is shown in binary, decimal and hexadecimal at once, so you can see which bit position actually changed instead of inferring it from a decimal number that jumped from 40 to 104.

Useful for Unix file permissions, hardware register values, feature-flag bitmasks, network mask arithmetic and any protocol that packs several fields into one integer.

How to use the Bitwise Calculator

  1. Enter the first value. Type a number in binary, decimal or hexadecimal.
  2. Pick an operation. Choose AND, OR, XOR, NOT, left shift or right shift.
  3. Enter the second value. Provide the other operand, or the shift distance.
  4. Compare the bits. Read the result in binary, decimal and hex to see which positions changed.

Bitwise Calculator features

  • AND, OR, XOR and NOT
  • Left and right shifts
  • Binary, decimal and hexadecimal shown for both operands and the result
  • Adjustable bit width for the binary display
  • Copy any value
  • Runs in your browser; nothing is uploaded

Frequently asked questions

Which operations are available?

AND, OR, XOR, NOT, and left and right shifts. Bit rotation is not included — rotating is not a JavaScript operator and has to be composed from a shift pair.

What are bitwise operations used for in practice?

Packing several true-or-false settings into one integer, then reading them back. AND with a mask tests a flag, OR sets one, XOR toggles one, and AND with an inverted mask clears one — which is how permission bits and hardware registers work.

Why show binary, decimal and hex together?

Because the bug is almost always visible in one of them and invisible in the others. A mask that is off by one bit is obvious in binary and looks like an arbitrary number in decimal; hex is the compact form most documentation uses.

What do the shifts actually do?

A left shift moves every bit up, which doubles the value per position; a right shift moves them down and halves it, discarding what falls off the end. They are the cheap way to multiply or divide by powers of two.

Why is NOT of a small number negative?

Because JavaScript's bitwise operators work on 32-bit signed integers, so inverting every bit of 5 gives -6. That is standard two's-complement behaviour, not an error in the calculation.