AND Calculator
Our free binary calculator solves AND Calculator problems. Get worked examples, visual aids, and downloadable results.
Reviewed for accuracy by Manoj Kumar, Mathematics Educator
AND Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser — no data is sent to any server.
Formula: A AND B: Output bit = 1 only when both input bits = 1
Worked example — 10110110 AND 11010100 = 10010100 (decimal 148, hex 0x94)
Formula
A AND B: Output bit = 1 only when both input bits = 1
The AND operation compares each bit of two numbers. For each bit position, the result is 1 if and only if both corresponding bits in the inputs are 1. Otherwise the result is 0. This is the most fundamental logical operation in digital computing.
Worked Examples
Example 1: Basic AND Operation with 8-bit Numbers
Problem:Calculate the AND of binary 10110110 (182) and 11010100 (212).
Solution:Align both numbers and apply AND bit by bit: 10110110 (182) & 11010100 (212) ---------- 10010100 (148) Bit 7: 1 AND 1 = 1 Bit 6: 0 AND 1 = 0 Bit 5: 1 AND 0 = 0 Bit 4: 1 AND 1 = 1 Bit 3: 0 AND 0 = 0 Bit 2: 1 AND 1 = 1 Bit 1: 1 AND 0 = 0 Bit 0: 0 AND 0 = 0
Result:10110110 AND 11010100 = 10010100 (decimal 148, hex 0x94)
Example 2: Subnet Mask AND Operation
Problem:Find the network address by ANDing IP 192.168.5.130 with subnet mask 255.255.255.192.
Solution:Convert last octet to binary: 130 = 10000010 192 = 11000000 AND operation on last octet: 10000010 (130) & 11000000 (192) ---------- 10000000 (128) First three octets: 192 AND 255 = 192, 168 AND 255 = 168, 5 AND 255 = 5
Result:Network address: 192.168.5.128 (the host is on the .128 subnet)
Frequently Asked Questions
What is the AND operation in binary arithmetic?
The AND operation is a fundamental bitwise logical operation that compares two binary numbers bit by bit and produces a result where each output bit is 1 only if both corresponding input bits are 1. If either input bit is 0, the result bit is 0. This operation is one of the most basic building blocks of digital circuits and computer processors. Every modern CPU uses millions of AND gates to perform calculations, route signals, and make decisions. The AND operation follows a simple truth table: 0 AND 0 equals 0, 0 AND 1 equals 0, 1 AND 0 equals 0, and 1 AND 1 equals 1.
How is the AND operation used in computer programming?
In programming, the AND operation serves many critical purposes. It is commonly used for bit masking, where you isolate specific bits from a number by ANDing it with a mask value. For example, to check if the lowest bit of a number is set (determining if the number is odd), you AND it with 1. Programmers also use AND for clearing specific bits, checking flags in bitmapped fields, and implementing permissions systems. In languages like C, Java, and Python, the bitwise AND operator is represented by the ampersand symbol. Network engineers use AND operations extensively to calculate subnet addresses from IP addresses and subnet masks.
What is the difference between AND, OR, and XOR operations?
AND, OR, and XOR are the three primary bitwise logical operations, each with distinct behavior. AND returns 1 only when both input bits are 1, making it the most restrictive operation. OR returns 1 when at least one input bit is 1, making it the most permissive of the three. XOR (exclusive OR) returns 1 only when the input bits differ, meaning one is 1 and the other is 0. These operations form the foundation of all digital logic. In practical terms, AND is used for masking and filtering, OR is used for combining flags and setting bits, and XOR is used for toggling bits and simple encryption schemes.
How does bit masking work with the AND operation?
Bit masking with AND is a technique for extracting or isolating specific bits from a binary number. You create a mask where the bits you want to keep are set to 1 and the bits you want to discard are set to 0. When you AND the original number with this mask, only the bits at positions where the mask has a 1 will pass through, while all other bits become 0. For example, to extract the lower 4 bits of the number 11010110, you AND it with the mask 00001111, which gives 00000110. This technique is essential in embedded systems, network programming, graphics processing, and any field where individual bits carry specific meanings.
What are AND gates and how do they work in digital circuits?
An AND gate is a physical electronic component that implements the AND logical operation in hardware. It has two or more input terminals and one output terminal. The output is high (logic 1) only when all inputs are simultaneously high. AND gates are built using transistors, and in modern CMOS technology, they combine NMOS and PMOS transistors to achieve this logic function. They are fundamental building blocks in processors, memory chips, and all digital electronics. Complex operations like addition, multiplication, and comparison are all built by combining AND gates with other gate types. A typical modern CPU contains billions of logic gates including AND gates.
Can the AND operation be used with negative numbers?
Yes, the AND operation works with negative numbers, but the results depend on how negative numbers are represented in binary. Most modern computers use twos complement representation, where negative numbers have a leading 1 bit. When you AND two numbers where one or both are negative, the operation still proceeds bit by bit across all bits including the sign bit. For example, in 8-bit twos complement, negative 1 is represented as 11111111, so ANDing any number with negative 1 returns the original number unchanged. Understanding twos complement is essential when performing bitwise AND on signed integers to avoid unexpected results in your programs.
What is the relationship between AND and Boolean algebra?
The AND operation is directly derived from Boolean algebra, the mathematical framework developed by George Boole in the 1840s. In Boolean algebra, AND corresponds to logical conjunction and is often represented by multiplication notation, so A AND B is written as A times B or simply AB. Boolean algebra defines several important properties of AND: it is commutative (A AND B equals B AND A), associative (A AND B AND C can be grouped any way), and distributes over OR. The identity element is 1 (A AND 1 equals A), and the annihilator is 0 (A AND 0 equals 0). These algebraic properties are used extensively in simplifying digital circuit designs.
How do I convert between binary and decimal for AND calculations?
Converting between binary and decimal is essential for understanding AND calculations. To convert binary to decimal, multiply each bit by 2 raised to its position power (starting from 0 on the right) and sum the results. For example, binary 1011 equals 1 times 8 plus 0 times 4 plus 1 times 2 plus 1 times 1, which equals 11 in decimal. To convert decimal to binary, repeatedly divide by 2 and record the remainders from bottom to top. For example, 13 divided by 2 gives quotient 6 remainder 1, then 3 remainder 0, then 1 remainder 1, then 0 remainder 1, so 13 in binary is 1101. AND Calculator handles both conversions automatically.
What are common mistakes when performing AND operations?
Several common mistakes occur when working with AND operations. The most frequent is confusing bitwise AND (which operates on individual bits) with logical AND (which evaluates entire expressions as true or false). In many programming languages, the single ampersand performs bitwise AND while the double ampersand performs logical AND. Another common error is forgetting to account for number width, since the same decimal number has different binary representations depending on whether you use 8, 16, or 32 bits. Beginners also sometimes confuse AND with OR, or forget that AND with 0 always produces 0 regardless of the other input. Always double-check your bit alignment when performing manual AND calculations.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator · Editorial policy
Related Calculators
🧮Annulus Area Calculator
Calculate annulus area with inputs, formulas, and instant results.
🧮Area Calculator
Calculate area with inputs, formulas, and instant results.
🧮Area of a Rectangle Calculator
Calculate the area, perimeter, and diagonal of a rectangle. Find missing sides from known area. Convert between metric and imperial area units.
🧮Area of Crescent Calculator
Calculate area of crescent with inputs, formulas, and instant results.
🧮Center of Mass Calculator
Calculate center of mass with inputs, formulas, and instant results.
🧮Centroid Calculator
Calculate centroid with inputs, formulas, and instant results.
🧮Chord Length Calculator
Calculate chord length with inputs, formulas, and instant results.
🧮Conic Sections Calculator
Calculate conic sections with inputs, formulas, and instant results.