StatGardenREF. DESK
Calculators/Maths/Bitwise Calculator
Maths

Bitwise Calculator

Runs AND, OR, XOR or NOT on two integers, showing the result in both decimal and binary.

Published 1 September 2026

What this calculator does

A bitwise calculator runs a logic operation on the individual binary digits of two numbers, rather than on the numbers as a whole. AND, OR and XOR each compare the numbers bit by bit and build a new number from the outcome of each comparison; NOT flips every bit of a single number.

These operations sit underneath a lot of ordinary programming: masking specific bits out of a value, toggling flags, checking whether a number is even, and packing several small settings into one integer. Working through the binary by hand is slow and error-prone once numbers get past a handful of bits, which is what this tool is for.

The formula

FormulaAND: 1 only where both bits are 1. OR: 1 where either bit is 1. XOR: 1 where the bits differ. NOT: flips every bit

Convert both integers to binary and line them up bit by bit. AND gives a 1 only where both bits are 1. OR gives a 1 where either bit is 1. XOR gives a 1 only where the bits differ. NOT takes a single number and flips every bit, shown here as an unsigned 32-bit result. The result is shown in both decimal and binary so you can check the working.

TermMeaning
ANDBit is 1 only where both inputs have a 1 in that position.
ORBit is 1 where at least one input has a 1 in that position.
XORBit is 1 where the two inputs differ, and 0 where they match.
NOTFlips every bit of a single number; here shown as an unsigned 32-bit result.

The inputs explained

FieldWhat to enter
First integerThe first whole number, entered as an ordinary decimal integer.
Second integer (ignored for NOT)The second whole number, ignored when the operation is NOT.
OperationWhich bitwise operation to apply to the two integers above.

When to use it

Masking specific bits

ANDing a value against a mask such as 15 (binary 1111) isolates only the lowest four bits of a number, discarding everything above them, which is how many low-level formats extract a packed field.

Combining flags

ORing several power-of-two values together packs multiple true/false settings into a single integer, a pattern still used in permission systems and hardware registers.

Spotting differences

XORing two numbers highlights exactly which bits differ between them, which is why XOR shows up in checksums, simple encryption and toggling a bit on and off with a repeated operation.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

AND, OR and XOR of 255 and 15

The same two integers, 255 (binary 11111111) and 15 (binary 00001111), run through each operation in turn.

255 AND/OR/XOR 15
OperationResult (decimal)Result (binary)
AND151111
OR25511111111
XOR24011110000
AND keeps only the bits both numbers share (15), OR keeps every bit either number has (255, since 15 is already a subset of 255), and XOR keeps only the bits that differ (240, the top four bits that 255 has and 15 does not).

Questions

How is bitwise AND different from ordinary multiplication?

They can agree for single bits (0 and 1), but bitwise AND works position by position across the whole binary representation, not on the numbers as quantities, so AND-ing 6 and 3 gives 2, not 18.

What does XOR with the same number twice do?

It returns the original value, because XOR-ing a bit with itself always gives 0, leaving every bit unchanged the second time. This is the basis of simple bit-toggling and some lightweight encryption schemes.

Why does NOT produce such a large decimal number?

NOT flips every bit, including the leading zero bits that were not shown. This calculator treats the result as an unsigned 32-bit number, so flipping a small value produces a number close to 4.29 billion rather than a small negative one.

How is this different from a bit-shift or two's complement calculator?

A bitwise calculator combines or flips bits between numbers using AND, OR, XOR and NOT. A bit-shift calculator instead moves the bits of a single number left or right, and a two's complement calculator represents negative numbers in binary; the three cover different operations on binary data.

To shift the bits of a single number left or right instead of combining two numbers, see the bit-shift calculator. For representing negative numbers in binary, see the two's complement calculator.