Bitwise AND Calculator: Mask, Clear & Isolate Bits Fast

Bitwise AND Calculator

Compute A AND B where each output bit is 1 only when BOTH input bits are 1. Enter operands in decimal, binary, or hex, see the bit-by-bit column alignment, read the result in every base, and use B as a mask to isolate or clear bits.

🔓Masking & AND Presets

🔢Operands

The first value. Enter it in the base you pick beside it.

How to read A. Binary uses 0 and 1; hex uses 0-9 and A-F.

The second value. Treat it as a mask to keep only chosen bits.

How to read B. Masks are often written in hex like 0x0F.

Padding width for the binary column view only.

Spaces every 4 or 8 bits make long binary easier to read.

Displays the aligned A, B, and result columns.

Adds a report of which bits of A survive the mask.

A AND B (decimal) 0 unsigned value
Result in binary 0 grouped bits
Result in hex 0x0 base 16
Set bits surviving 0 ones in the result

🧮1-Bit AND Truth Table

Bit ABit BA AND BMeaning
000Both off, stays off
010One off, cleared
100One off, cleared
111Both on, survives

🧰Formula Snapshot

&AND operator
1&1= 1 only
0x0Fkeep low 4
0xFFkeep low 8

📋Common AND Masks Reference

Mask (hex)Binary (8-bit)PurposeExample
0x010000 0001Test bit 0 / parity13 & 0x01 = 1
0x0F0000 1111Keep low nibble0xAB & 0x0F = 0x0B
0xF01111 0000Keep high nibble0xAB & 0xF0 = 0xA0
0x7F0111 1111Clear the top bit200 & 0x7F = 72
0x801000 0000Test the sign bit255 & 0x80 = 128
0xFF1111 1111Isolate low byte0x12FF & 0xFF = 0xFF
0x030000 0011Keep low 2 bits14 & 0x03 = 2
0xFE1111 1110Force even / clear bit 013 & 0xFE = 12

🗃AND Comparison Grid

ABA AND B (dec)BinaryHexUse Case
1710x0F110000 10110x0BKeep low nibble
1710xF01601010 00000xA0Keep high nibble
121080000 10000x08Common bits only
2551281281000 00000x80Test top bit
13110000 00010x01Odd number check
14100000 00000x00Even number check
1708500000 00000x00No shared bits
655350xFF2551111 11110xFFIsolate low byte
2000x7F720100 10000x48Clear top bit
7440000 01000x04Isolate bit 2

📐Bit Position Values (Powers of Two)

Bit indexValue (dec)HexBinary flag
010x010000 0001
120x020000 0010
240x040000 0100
380x080000 1000
4160x100001 0000
5320x200010 0000
6640x400100 0000
71280x801000 0000

Formula Breakdown

Rule: 1 AND 1 = 1An output bit is 1 only when both input bits are 1. Every other pairing (0&0, 0&1, 1&0) yields 0, so AND never turns a 0 into a 1.
Column alignmentPad A and B to the same width, then AND each column top to bottom. 12 = 1100 and 10 = 1010 give 1000, which is 8.
Masking to keep bitsPut 1 in the mask where you want to keep a bit and 0 where you want to drop it. x & 0x0F keeps the low four bits and clears the rest.
Isolating a bytex & 0xFF keeps only the low eight bits, extracting one byte from a larger number regardless of what sits above it.
Parity testx & 1 looks at bit 0 only. A result of 1 means x is odd; a result of 0 means x is even, faster than dividing.
Clearing bitsTo clear specific bits, AND with the complement of a mask: x & 0xFE forces bit 0 to 0, rounding an odd number down to even.
Set-bit countCounting the 1s in the result (its population count) tells you how many bits survived the AND, a quick sanity check on a mask.

💡Practical Masking Tips

Build masks in hex: One hex digit maps to exactly four bits, so 0x0F is 0000 1111 and 0xFF is 1111 1111. Writing masks in hex keeps a 32-bit value to just 8 characters and makes it obvious which nibble you are keeping or clearing at a glance.
AND clears, it never sets: Because 1 AND 1 is the only pairing that returns 1, ANDing can only keep or remove existing 1 bits. To turn bits on, use OR; to isolate or switch bits off, reach for AND with a carefully chosen mask.

In computing terms, the AND function is a strict form of logical calculation. Imagine it’s like a gatekeeper who poses one simple question for each bit position: Are both these things present in this position? If so, then we keep the bit on; if not, we turns it off. Because it is binary demand, the AND operator has some uses when you want to isolate individual bits or clear out unwanted information.

Try typing in any two numbers in calculator above and watch as it filters out noise, leaving just signal that’s common between the two number. And here’s how it works: Zero AND zero = zero; zero AND one = zero; one AND zero = zero; and one AND one = one. Anything except a 1 or a 0 in either input produce zero. That means no matter how many zeroes and ones goes into this operation, none come out that weren’t present in both of the inputs. It only retains what they have in common.

How Bitwise AND Works

And this fact is why developers use it for masking. They create a secondary number, called a mask. And put a one wherever they want something preserved and a zero elsewhere. When you AND your data based off that mask, all those ones will pass through your original bits unscathed while all those zeros turns everything else into nothing. It is a perfect tool for reducing data.

Now let’s think about the lower four bits of a byte. They’re often called a nibble. How would we isolate those? Simply AND the value with 0x0F. That’s because in binary, that mask is 0000 1111. The leading zeros wipe out the top half of the number and the ones on the end preserves only bottom half. You get precisely what you asked for and no more.

Look at it in calculator and you’ll see how it lines up perfectly: both operands are stacked so you can trace through columns and see how they resolve. Being able to see how the columns align in binary makes it clearer why some hex values behave as masks. It translates abstract logic into something you can see, arithmetic.

And the reason for masking isn’t just to keep bits around but to clear them too without mucking up the rest. You OR your value with a mask that has zeros where you want to force a bit to zero, and ones elsewhere. So if we have 0xFE (all ones except the last bit) then when you AND anything with 0xFE, that last bit will be cleared. That’s like rounding an odd number down to the next even one. It is faster than division, and there is no possibility of messing up other data fields packed into same integer or setting unwanted flags.

Another common example is testing flags. In embedded systems in particular, they will cram several booleans into a single byte of memory. Ready? Error? And so on. Want to see if your error flag is set? Then you AND the status byte against 0x02. If your result isn’t zero then the error bit was there. Otherwise that slot was clear. Handy for checking if just a single bit is set or not. No need to unpack the whole variable. Atomic, efficient at hardware level.

Beginners may be tripped up by the layer of translation introduced when working from multiple bases. Hex is native tongue of bit patterns (each digit maps directly to four binary bits), but we’re all used to using decimal to count. The calculator lets you freely mix these formats. For instance, you could type in a hex mask with a decimal address into same operation. Behind the scenes, it converts everything so that they line up correctly, no matter which format you typed them in. That flexibility reflects what happens in real code environments where constants are often defined in hex to make them easier to read, even though they arrives as integers at run time.

In addition to producing the answer, the calculator gives a visual breakdown of what is going on, showing the column-by-column evaluation taking place within CPU. Which bits are kept? Which bits is tossed? Transparency like this catches errors before they make it into production code. A single bad bit in a mask silently corrupts data in a way that’s painful to track down later. You should of saved yourself some time and verify the pattern first.

Bit manipulation doesn’t tolerate guesswork, but it does reward precision. Binary flags don’t approximate; they’re either on or off. The AND operation create this discipline by showing the intersection between two bit patterns. This makes it easier to visualize how information move within digital systems. It conveys abstract numbers in tangible forms you can examine and confirm.

It’s that clarity, not the computation itself. Which makes it so valubale.

Bitwise AND Calculator: Mask, Clear & Isolate Bits Fast