Skip to content
Hex Calculator

Hex AND Calculator

Bitwise AND two hex values and see the result bit by bit — the operation low-level code uses to mask out (clear) unwanted bits.

Bit width
Hexadecimal
0x00
Decimal
0

Binary, aligned by bit

A: 11110000
B: 00001111
=: 00000000
Swapnil Sanghvi

Built by

Swapnil Sanghvi

Full-Stack Web Developer & WordPress Developer

Swapnil Sanghvi is a full-stack web and WordPress developer, UI designer, and full-time freelancer who builds and maintains Hex Calculator.

Hex AND Calculator tool preview card from Hex Calculator
Share preview: this is the card that appears when you share the Hex AND Calculator page on social media.

Further reading: Bitwise operation — Wikipedia

How to AND Two Hex Values

Line the two values up bit by bit. For each position, the result bit is 1 only if both inputs have a 1 there — if either input has a 0, the result bit is 0. It's the strictest of the bitwise operations: every bit has to "agree" on 1 to survive.

Hex AND Example, Step by Step

1234 AND 00FF = 0034

0x1234 & 0x00FF = 0x0034

  0001 0010 0011 0100
& 0000 0000 1111 1111
---------------------
  0000 0000 0011 0100
StepDescriptionResult
Align bits1234 = 0001001000110100, 00FF = 000000001111111116 bits each
AND each bit pairtop byte ANDed with all zeros clears it; low byte ANDed with all ones keeps ittop byte cleared, low byte kept
Resultonly the low byte of 0x1234 survives0x0034

This is the standard 'mask off the low byte' pattern — ANDing with 0x00FF always clears everything except the lowest 8 bits, regardless of what the original value was.

Where Hex AND Actually Comes Up

Isolating a Byte From a Larger Value

ANDing a 16- or 32-bit value with 0xFF keeps only the lowest byte and clears the rest — a routine step when unpacking a multi-byte value one byte at a time.

value & 0xFF -> low byte only

Checking If a Specific Flag Bit Is Set

ANDing a status register against a single-bit mask and checking whether the result is nonzero is the standard way to test one flag without disturbing the others.

status & 0x04 tests bit 2

Rounding Down to a Power-of-Two Boundary

ANDing an address against the inverse of an alignment mask clears the low bits, rounding the address down to the nearest aligned boundary — common in memory allocators.

addr & ~0xF aligns to 16 bytes

Why Use This Calculator Instead of Doing It by Hand

  • Shows aligned binary for both operands and the result, not just the final hex
  • Supports 8/16/32/64-bit widths so leading zero bits are handled correctly
  • Runs entirely in your browser — nothing you type gets sent anywhere
  • Includes OR, XOR, and NOT in the same calculator if you need to switch operations

Limitations

  • Combines two values at a time — chain results manually if you need to AND three or more values together.
  • The bit-width setting only controls how the binary breakdown is padded and displayed — it doesn't change which bits the AND itself compares.

Frequently Asked Questions

How does bitwise AND work?

AND compares two values bit by bit — a result bit is 1 only when both inputs have a 1 in that position, otherwise it's 0.

What is AND used for in practice?

Masking — ANDing a value against a mask clears every bit outside the mask, which is how code isolates a specific field (like a single byte) out of a larger value.

Why is 0xFF a common AND mask?

0xFF is eight 1 bits, so ANDing any value with it keeps only the low 8 bits (one byte) and clears everything above that — a very common way to isolate the low byte of a larger number.

Does bit width change an AND result?

Not the AND itself — AND only combines bits that exist in both operands — but the bit width controls how many leading zero bits each operand is padded to before comparing, which matters if you're checking a specific bit position.

What's the difference between AND and OR here?

AND clears bits (needs both inputs to have a 1 to keep it); OR sets bits (needs only one input to have a 1). Use AND to mask down, OR to combine flags up.