Hex AND Calculator

Calculates the bitwise AND of two hexadecimal values: the shorter value is left-padded with zero digits to match the longer one's width, then AND is applied across every nibble-aligned bit position, producing a 1 only where both bits are 1. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

Bitwise AND is one of the most common operations in low-level programming, used constantly to mask off or test specific bits within a hex-encoded value.

This tool computes the bitwise AND of two hexadecimal values, so you can see exactly which bit positions are 1 in both inputs.

What Is Hex AND Calculator?

A calculator for the bitwise AND of two hex values: it compares the two values bit by bit and keeps a 1 only where both operands have a 1 at that position.

Like the other two-operand hex gate calculators in this category, it automatically left-pads the shorter operand with zero digits so both values line up bit-for-bit before combining them.

How Hex AND Calculator Works

Both Value A and Value B are validated as hex strings, then the shorter is left-padded with leading zero digits to match the longer value's digit count.

The padded values are combined bit-by-bit with AND, and the result is formatted as an uppercase hex string padded to that same shared width.

When To Use Hex AND Calculator

Use it to mask a hex value against a bitmask, keeping only the bits that are set in both, for example testing which flag bits are active in a status byte.

It's also a useful teaching tool for showing how AND behaves on real multi-bit hex data rather than single bits.

Features

Advantages

  • Automatically handles operands of different lengths by zero-padding, so you don't have to align widths by hand first.
  • Works on arbitrarily long hex values via BigInt, not limited to a fixed 8/16/32/64-bit width.
  • Instant, deterministic, fully client-side.

Limitations

  • Zero-padding the shorter operand assumes you want it treated as a smaller number within a larger field; pad manually first if your context expects different alignment.
  • Only combines two operands at a time; chain the tool manually if you need to AND together more than two values.

Examples

AND of two mixed bit patterns

Input

A: A5, B: 3C

Output

24

A5 (10100101) AND 3C (00111100) = 24 (00100100), a 1 only where both inputs had a 1.

Masking with all-1s leaves the other value unchanged

Input

A: A5, B: FF

Output

A5

ANDing any value with FF (11111111) leaves every bit of the other operand untouched.

Best Practices & Notes

Best Practices

  • Confirm both values are the width you intend before relying on the auto-padding, since a short operand gets left-padded with zeros.
  • Use an all-1s mask (like FF for 8 bits) when you want to pass a value through unchanged while confirming the AND logic is wired correctly.

Developer Notes

Implemented with JavaScript BigInt: after zero-padding both operands to the same digit width, it computes `a & b` directly (no complement step), avoiding JavaScript's native 32-bit-limited bitwise operators for operands wider than 32 bits.

Hex AND Calculator Use Cases

  • Masking a status byte or register to isolate specific flag bits
  • Teaching or demonstrating the AND logic gate using concrete multi-bit hex examples
  • Cross-checking a manually-computed AND result

Common Mistakes

  • Expecting AND to set bits rather than clear them; it can only keep bits that were already 1 in both inputs, never turn a 0 into a 1.
  • Forgetting that a short operand gets zero-padded on the left, which can change the intended meaning if it was meant to be right-aligned instead.

Tips

  • Try masking a value against FF (or FFFF, etc.) to confirm the pass-through behavior of an all-1s mask.
  • Compare the result with the Hex OR Calculator on the same inputs to see how AND and OR diverge on mixed bit patterns.

References

Frequently Asked Questions