b2KIT

Bit Manipulation Calculator

Perform bitwise operations (AND, OR, XOR, NOT, shifts) with visual binary representation and step explanation.

Tested tool guide Tested browser tools Checked August 16, 2026

What Bit Manipulation Calculator does, with a checked example

This calculator takes one or two decimal or binary numbers and performs bitwise operations such as AND, OR, XOR, NOT, and left/right shifts. It displays the binary representation of each operand and result, and gives a step-by-step explanation of how the operation proceeds bit by bit. The most common surprise is that bitwise operations work on the full binary representation of the number, not on its decimal digits; for example, 5 AND 3 equals 1, not 0 or 5, because only the lowest bit is set in both.

Worked example

A concrete input and expected output from the current implementation.

Input

5 AND 3

Expected output

Result: 1 (binary: 001 & 011 = 001). Explanation: 5 = 101, 3 = 011. AND: bit 0: 1 & 1 = 1, bit 1: 0 & 1 = 0, bit 2: 1 & 0 = 0. Result: 001 = 1.

The AND operation compares each corresponding bit: only bit 0 is 1 in both numbers, so the result is binary 001, which is decimal 1.

How the result is produced

1

Binary conversion

Each operand is converted to its binary representation using the minimum number of bits needed to represent the maximum operand, with leading zeros added for clarity. The tool then aligns the binary strings and performs the selected operation bit by bit, from least significant bit to most significant bit, and shows the resulting binary string.

2

Step-by-step explanation

For each bit position, the tool lists the operand bits and the result of the operation. For shifts, it shows how bits move left or right, including which bits fall off the end and what value fills the vacated positions (0 for logical shifts). The final step converts the binary result back to decimal and displays it alongside the binary.

Good uses

  • Debugging low-level code by checking what a bitmask like 0b1010 & 0b0110 actually evaluates to.
  • Learning how bitwise operations work by experimenting with small numbers and seeing the bit-by-bit result.
  • Verifying manual calculations for bit manipulation tasks such as setting or clearing a specific bit using OR or AND with a mask.

Limits and checks

  • The tool only works with non-negative integers; negative numbers or decimal fractions are not accepted, and entering them will produce an error.
  • Shift amounts outside the bit width (e.g., shifting right by more than the number of bits) yield 0, but the tool may show a long explanation that can be misread as an overflow.
  • The result is always shown in the minimum number of bits for the result, so leading zeros are omitted, which can be confusing when comparing to the operands' padded binary strings.

Common questions

Does the tool support negative numbers or signed integers?

No, it only accepts non-negative integers. For signed operations, you would need to think about two's complement, but this tool does not handle that. Entering a negative number will cause an error message.

What happens if I shift by more than the bit width?

For example, shifting a number right by 8 when it has only 8 bits will result in 0, because all bits fall off the end. The tool will show the step-by-step process and final result as 0, which is mathematically correct for logical shifts.

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