ToolLineup

Bitwise Calculator

This bitwise calculator works out AND, OR, XOR, NAND, NOR, XNOR, NOT and shifts, displaying both operands and the result aligned bit for bit so you can see exactly which positions changed. That alignment is the point — a decimal answer tells you nothing about why, whereas three rows of bits makes a mask or a flag combination immediately obvious. The arithmetic uses arbitrary-precision integers rather than the built-in operators, which coerce to 32-bit signed values: that is why the 64-bit width genuinely works here instead of silently wrapping at 2,147,483,647 the way most calculators do.

How it works

Calculates AND, OR, XOR, NAND, NOR, XNOR, NOT and shifts on two values, showing the operands and the result lined up bit for bit so you can see exactly which positions changed.

The arithmetic uses arbitrary-precision integers rather than JavaScript’s built-in operators, which silently truncate to 32 bits. That means the 64-bit width genuinely works instead of wrapping at 2,147,483,647.

Everything runs in your browser — nothing you enter is sent to a server.

A0000 110012
B0000 101010
=0000 10008
Decimal
8
Hexadecimal
0x8
Octal
0o10
Binary
00001000

Calculated at 8 bits. Values are wrapped into the unsigned range for that width.

Reading the bit rows

The three rows are the whole reason to use a bitwise calculator rather than a language REPL. Line up A, B and the result and the behaviour of each operation is obvious at a glance:

  • AND keeps a bit only where both operands have it — that is masking.
  • OR sets a bit where either has it — that is combining flags.
  • XOR sets a bit where exactly one has it — that is toggling, and it is its own inverse.
  • Shifts move every bit left or right, which multiplies or divides by powers of two.

Why 32 bits is not enough

JavaScript's bitwise operators convert their operands to 32-bit signed integers before doing anything. Anything above 2,147,483,647 wraps to a negative number, with no warning. This calculator uses arbitrary-precision integers, so the 64-bit width behaves the way you would expect.

Width matters

NOT of 0 is 255 in 8 bits, 65,535 in 16 and 18,446,744,073,709,551,615 in 64. There is no correct answer without knowing the width, so set it to match the type you are actually working with.

Frequently asked questions

What does the bitwise calculator do?

It applies AND, OR, XOR, NAND, NOR, XNOR, NOT or a shift to two values and shows both operands and the result aligned bit for bit.

Does it really support 64-bit?

Yes. It uses arbitrary-precision integers rather than the built-in operators, which truncate to 32 bits. Most online calculators wrap silently above 2,147,483,647.

Can I enter hex or binary?

Yes. Choose the input base and enter values in decimal, hexadecimal, binary or octal. The result is shown in all four.

What does the width setting do?

It sets how many bits the result is wrapped to. NOT of 0 is 255 at 8 bits and 65,535 at 16, so the width has to match the type you are reasoning about.

What are these operations used for?

Packing several true/false flags into one number, extracting fields with a mask, toggling bits, and permission systems where each bit is one permission.

Is my calculation sent anywhere?

No. It runs entirely in your browser.

Related tools