Binary Calculator
Binary arithmetic (+−×÷), bitwise AND/OR/XOR/NOT/shifts, and base conversion between binary, octal, decimal and hex.
Inputs
Binary
11111111
Decimal
255
Hexadecimal
FF
Octal
377
Step by step
Decimal input
= 255
Binary (base 2)
= 11111111
Octal (base 8)
= 377
Hexadecimal (base 16)
= 0xFF
How it works
Binary is base-2: only digits 0 and 1. Each position is a power of 2. Binary arithmetic follows the same rules as decimal but carries happen at 2 (not 10). Bitwise operations work bit-by-bit on the binary representations: AND returns 1 only where both bits are 1; OR where at least one is 1; XOR where exactly one is 1; NOT flips all bits. Shifts multiply (<<) or divide (>>) by powers of 2.
Formulas
Binary to decimal
d = Σ bᵢ × 2ⁱ (sum of bit values)
Bitwise identities
AND: 1 only if both 1. OR: 1 if either 1. XOR: 1 if exactly one 1.
Frequently Asked Questions
What is 255 in binary?
255 = 11111111₂ — eight 1 bits, because 2⁸ − 1 = 255. It's also 0xFF in hexadecimal and 0o377 in octal. This is the maximum value of an unsigned 8-bit byte.
What does XOR do and why is it useful?
XOR (exclusive OR) outputs 1 only when the two input bits differ. It's used in cryptography (XOR with a key), error detection (parity), and the classic bit-swap trick (a^=b; b^=a; a^=b swaps two variables without a temporary).
How does left-shift multiply by 2?
Shifting bits left by n places is the same as multiplying by 2ⁿ. For example, 5 = 101₂; 5 << 1 = 1010₂ = 10 = 5 × 2. Right shift divides by 2ⁿ (integer division).