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:
| A | B | A & B |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
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.
