Calculate bitwise AND operation between two numbers
Calculate bitwise AND operations between two numbers instantly with our free online AND calculator. This tool helps programmers, students, and computer science professionals perform binary AND operations with visual bit-by-bit explanations. Simply enter two numbers and see the AND result in decimal, binary, and hexadecimal formats in real-time.
AND returns 1 only when both bits are 1, otherwise returns 0.
Bitwise AND calculator performs logical AND operation on binary numbers. Each bit pair is compared: 1 AND 1 = 1, all other combinations = 0. Essential for masking bits, checking flags, network subnet calculations, and low-level programming.
Input two numbers (binary, decimal, or hex). The calculator converts both to binary, aligns them, and performs AND on each bit position. A bit in the result is 1 only if BOTH corresponding input bits are 1.
AND truth table: 0&0=0, 0&1=0, 1&0=0, 1&1=1. In programming: & operator (C, JavaScript, Python). Used to: clear bits (mask with 0s), test bits (mask with 1s), extract bit fields, calculate network addresses.
IP AND netmask = network address.
192.168.1.100 AND 255.255.255.0 = 192.168.1.0Test if specific permission bits are set.
Extract specific bits from a value.
value & 0xFF extracts lowest byten & 1 = 0 if even, 1 if odd (checks lowest bit).
// Basic AND
console.log(12 & 10); // 8
// 1100 (12)
// 1010 (10)
// ----
// 1000 (8)
// Check if number is even
const isEven = n => (n & 1) === 0;
isEven(4); // true
isEven(7); // false
// Extract lowest byte
const getLowByte = n => n & 0xFF;
getLowByte(0x1234); // 0x34 (52)
// IP subnet calculation
function getNetworkAddress(ip, mask) {
const ipParts = ip.split('.').map(Number);
const maskParts = mask.split('.').map(Number);
return ipParts.map((p, i) => p & maskParts[i]).join('.');
}
getNetworkAddress('192.168.1.100', '255.255.255.0'); // "192.168.1.0"AND outputs 1 only where both inputs are 1. Use for masking, flag checking, and subnet calculations.
Use bitwise AND for subnet calculations, permission/flag checking, bit extraction, and any operation requiring selective bit clearing or testing.
IP AND mask gives network address. For 192.168.1.100/24: 11000000.10101000.00000001.01100100 AND 11111111.11111111.11111111.00000000 = 192.168.1.0. The mask zeros out the host portion.