b2KIT

Bitwise Operation Calculator

Perform AND, OR, XOR, NOT, shifts, and rotations on binary, hex, or decimal values. Visualize bit patterns.

Tested tool guide Tested browser tools Checked August 16, 2026

What Bitwise Operation Calculator does, with a checked example

Takes up to two values in binary, hex, or decimal - or one value for NOT, shifts, and rotations - applies a bitwise operator bit by bit, and shows the result in every base plus a bit grid that lines each operand up by place value. You can trace which input bit produced which output bit. The usual surprise is NOT: it flips every bit, it is not negation. On 8 bits, NOT 0x0F is 0xF0, while negation of the same value is 0xF1, because two's complement is NOT plus 1. Width decides what NOT, shifts, and rotations return, so set it deliberately.

Worked example

A concrete input and expected output from the current implementation.

Input

0xA5 XOR 0x5A

Expected output

0xFF (binary 11111111, decimal 255)

A5 hex is binary 10100101 and 5A is 01011010. XOR sets a bit only where the two operands differ; every position differs, so the result is 11111111, which is FF hex and 255 decimal.

How the result is produced

1

Bit-by-bit application

Each operator is applied per position: AND leaves a bit set only where both operands have 1, OR where either does, XOR where exactly one does, NOT flips every bit. Operands align at the least significant bit; the shorter is zero-padded on the left (0b101 beside 0b11001 reads as 00101). Shifts push bits left or right and discard what falls off the end; rotations wrap it to the other side.

2

Parsing and display

The base is read per operand: 0x or 0b prefixes mark hex and binary, plain digits read as decimal, and operands may mix bases. Inputs convert to one bit string; the result renders in all three bases at once - 42, 0x2A, and 0b101010 are the same value in three columns. The bit grid shows each operand as a row of cells by place value and the result row below.

Good uses

  • Subnetting: AND an IP address with its netmask to confirm the network address, and NOT the mask to get the wildcard, before writing a firewall rule or router config.
  • Flag and bit-field work: check whether bit n of a status byte is set with value AND (1 << n), toggle it with XOR (1 << n), or pull the low nibble from a register dump with AND 0x0F.
  • Verifying a mask before coding: turn a mask such as 0b11100000 into hex or decimal, inspect the bit pattern, and confirm which bits of a packed value it keeps or clears before hard-coding it into firmware or a parser.

Limits and checks

  • NOT, shifts, and rotations are width-dependent. NOT 0x0F is 0xF0 at 8 bits but 0xFFFFFFF0 at 32 bits; a left shift can silently drop bits that overflow the working width; and a rotate wraps within it, so 0b0001 rotated right by 1 is 0b1000 at 4 bits but 0b10000000 at 8. A result means something only together with the width it was computed at.
  • Right shifts come in two flavors: logical shifts fill the vacated bits with 0, arithmetic shifts copy the sign bit instead, and the two differ for any value with the top bit set. The result column is also unsigned until you say otherwise: the pattern 0xFF reads as 255 unsigned or -1 signed, and the tool shows the pattern, not the signedness.
  • Entry base is easy to misread: '10' is ten in decimal, 0b10 (two) in binary, and 0x10 (sixteen) in hex, so trust the base the tool reports rather than the one you assumed. Mixed-base operands combine correctly, but only if each was entered in the base you intended. The visualization pads with leading zeros, so count a value's bits from the right, not the visible left edge of its row.

Common questions

What is the difference between a shift and a rotation?

A left shift moves every bit one position up and fills the bottom with 0, losing whatever falls off the top; a rotation moves the top bit around to the bottom instead of losing it. So 0b10000001 shifted left by 1 is 0b00000010, but rotated left by 1 it is 0b00000011 - the top 1 wraps to the low bit. Rotations preserve every bit; shifts discard.

Can I enter negative numbers like -5?

Some bitwise calculators accept negative decimal input and convert it to two's complement at the working width; others only take non-negative values. If yours rejects the minus sign, enter the two's complement form yourself: at 8 bits, -5 is 0xFB, which also reads as 251 unsigned, so check the width before trusting either reading. Alternatively compute NOT 5 + 1, which is exactly two's complement negation.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools