toolery

Bitwise calculator

Perform AND, OR, XOR, NOT, and shift operations on two numbers, with the bit-by-bit comparison shown alongside the result.

Result
—
Hex
—

How it works

A bitwise operation compares two numbers one bit position at a time, independently of every other position — there is no carrying the way there is in addition. AND gives a 1 only where both inputs have a 1, OR wherever either does, and XOR only where they differ, which is what makes XOR reversible: apply it twice with the same value and you are back where you started. NOT flips every bit, and the result depends entirely on the width you are working in, since flipping 8 bits and flipping 32 bits give very different numbers. Shifting moves every bit left or right, which multiplies or divides by powers of two — bits pushed past the edge are gone, and that is flagged above when it happens.

Used this in a paper or lesson?