Bitwise And Calculator

Written by:
PK

Use this bitwise AND calculator to compare bits and return 1 only where both are 1. AND is commonly used for masking bits, checking flags, and clearing specific bits.

Bitwise AND calculator

Using the calculator

Enter two numbers and select an input format for each: Decimal, Hex, Binary, or Octal. You can also type prefixes directly (0xFF for hex, 0b1010 for binary, or 0o17 for octal) and the tool will auto-detect the format.

The result displays in all formats simultaneously: decimal (signed and unsigned), hexadecimal, octal, and a 32-bit binary representation with spaces every 8 bits for readability.

How bitwise AND works

Bitwise AND (written as &) compares each bit of two numbers. It returns 1 only if both bits are 1, otherwise 0. Think of it as "both must be true."

The AND truth table:

ABA & B
000
010
100
111

Bitwise AND example

Comparing the binary representations bit by bit:

00101100 (44)
00011000 (24)
────────
00001000 (8)

Only bit position 3 has 1s in both numbers, so only that bit is 1 in the result. In other words: 44 & 24 = 8.

Common uses for AND

Bit masking: AND with a mask to extract specific bits. For example, color & 0xFF extracts the lowest 8 bits (blue channel from RGB).

Check if bit is set: If (value & flag) != 0, that flag bit is set.

Clear bits: AND with a mask of 0s in positions you want to clear, 1s elsewhere. For example, x & ~(1 << n) clears bit n.

Check even/odd: (n & 1) returns 0 for even numbers, 1 for odd - faster than modulo in some contexts.

      

PK

PK started DQYDJ in 2009 to research and discuss finance and investing and help answer financial questions. He's expanded DQYDJ to build visualizations, calculators, and interactive tools.

PK lives in New Hampshire with his wife, kids, and dog.

Don't Quit Your Day Job...

DQYDJ may be compensated by our partners if you make purchases through links. See our disclosures page. As an Amazon Associate we earn from qualifying purchases.
Sign Up For Emails
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram