bitwise and calculator

Bitwise AND Calculator

Enter two non-negative integers to compute A & B. You can use decimal numbers, binary, or hexadecimal.

Tip: In auto mode, plain numbers are treated as decimal.
Quick examples:

What is a bitwise AND calculator?

A bitwise AND calculator applies the AND operator to each matching bit position of two integers. The rule is simple: a resulting bit is 1 only when both input bits are 1. In every other case, the result is 0.

This operation is common in software engineering, networking, embedded systems, and performance-sensitive code. A calculator like this helps you verify values quickly without manually converting each number in your head.

How bitwise AND works

The core truth table

  • 1 AND 1 = 1
  • 1 AND 0 = 0
  • 0 AND 1 = 0
  • 0 AND 0 = 0

For example, with 8-bit formatting:

  • 13 = 00001101
  • 7 = 00000111
  • 13 AND 7 = 00000101 (which is 5)

Practical uses of bitwise AND

1) Bit masking

Bit masking lets you extract or keep only certain bits. If you have a value and a mask, value & mask keeps the bits where the mask has 1s and clears the rest.

2) Permission flags

Many systems store multiple boolean settings in a single integer. AND is used to check whether a specific permission bit is enabled.

3) Network address calculations

In IP networking, subnet operations rely on AND between an IP address and a subnet mask to identify the network portion.

4) Even/odd checks and low-level optimization

A quick way to test oddness is n & 1. If the result is 1, the number is odd; if 0, it is even.

How to use this calculator correctly

  • Enter both inputs as non-negative integers.
  • Use auto mode for mixed formats like 42, 0b101010, and 0x2A.
  • Set a display width to make binary values easier to compare visually.
  • Read the aligned binary block in the output to see exactly where bits were kept or cleared.

Common mistakes

Confusing logical AND with bitwise AND

Logical AND (&&) works on boolean expressions. Bitwise AND (&) works on integer bit patterns.

Mixing number bases unintentionally

If you type plain values without prefixes in auto mode, they are treated as decimal. Use 0b for binary and 0x for hexadecimal to avoid errors.

Ignoring display width

Different bit widths can make the same numeric value look different in binary. Padding to a fixed width improves readability and consistency.

Final takeaway

A reliable bitwise and calculator is a small but powerful tool. It helps you reason about masks, flags, and binary transformations with confidence. Use it while debugging, while learning, or when validating production values before they become bugs.

🔗 Related Calculators