Perform binary arithmetic and conversions
Perform binary arithmetic operations including addition, subtraction, multiplication, division, AND, OR, and XOR. See results in binary, decimal, hexadecimal, and octal. This tool runs entirely in your browser.
Binary arithmetic and bitwise operations are fundamental to computer science and low-level programming. Every CPU performs billions of binary operations per second — addition, subtraction, and logical operations (AND, OR, XOR, NOT) on binary numbers. Understanding these operations is essential for tasks like network subnet calculations, hardware register manipulation, graphics programming, encryption algorithms, and embedded systems development. Bitwise AND is used for masking specific bits, OR for setting bits, XOR for toggling bits and simple encryption, and shift operations for efficient multiplication/division by powers of 2. This calculator shows results in binary, decimal, and hex simultaneously, making it invaluable for debugging and learning.
AND masks specific bits — if both bits are 1, the result is 1. Common uses: extracting specific bits from a value (bit masking), checking if a flag is set, and IP subnet calculations where you AND an IP with a subnet mask.
XOR returns 1 when bits are different, 0 when they're the same. It's used for toggling bits, simple encryption (XOR cipher), swap algorithms without temp variables, and error detection (parity checking).
Left shift (<<) moves bits left, effectively multiplying by 2 for each position. Right shift (>>) divides by 2. These are faster than multiplication/division in hardware and are used extensively in performance-critical code.
Hex is a compact way to represent binary — each hex digit maps to exactly 4 bits. 0xFF in hex equals 11111111 in binary equals 255 in decimal. It's much easier to read than long binary strings.
Two's complement is how computers represent negative numbers in binary. The leftmost bit indicates sign (0=positive, 1=negative). To negate a number: flip all bits and add 1. This allows addition hardware to handle subtraction too.