Math · Live
Binary calculator —
arithmetic & base conversion.
Add, subtract, multiply, and divide binary, decimal, hexadecimal, and octal numbers. Or switch to Convert mode to see any number instantly expressed in all four bases simultaneously, with a bit table and powers-of-2 breakdown.
Inputs
Binary arithmetic
Operation
Result
Operands
Both inputs in every base
A = 10
BIN
1010
DEC
10
HEX
A
OCT
12
B = 5
BIN
101
DEC
5
HEX
5
OCT
5
Field guide
Binary, decimal, hex, and octal — how number bases work.
What is binary (base 2)?
Binary is the number system that uses only two digits: 0 and 1. Every modern computer stores and processes data exclusively in binary — each 0 or 1 is a bit, the smallest unit of information. Eight bits form a byte, which can represent 2⁸ = 256 distinct values (0–255).
Binary arithmetic follows the same positional rules as decimal, except each position represents a power of 2 rather than a power of 10. The binary number 1011 equals:
The four number bases
While humans use base-10 (decimal) for everyday arithmetic, computer science regularly uses three additional bases:
- Base 2 (binary). Used internally by all digital hardware. A 32-bit integer can hold values from 0 to 2³² − 1 = 4,294,967,295.
- Base 8 (octal). Uses digits 0–7. One octal digit represents exactly 3 bits. Commonly used in Unix file permission modes (e.g.,
chmod 755=rwxr-xr-x). - Base 10 (decimal). The standard human number system. Used for human-readable values in programming, configuration, and UI.
- Base 16 (hexadecimal). Uses digits 0–9 and letters A–F. One hex digit represents exactly 4 bits (a nibble). A pair of hex digits represents one byte. Used extensively in programming for memory addresses, RGB color codes, MAC addresses, and cryptographic hashes.
Converting between bases
The canonical method for all base conversions is to go through decimal:
- Any base → decimal: Multiply each digit by its corresponding power of the base and sum. E.g., hex
2F: 2×16¹ + 15×16⁰ = 32 + 15 = 47. - Decimal → any base: Divide by the target base repeatedly, recording remainders. Read the remainders in reverse. E.g., 47 ÷ 16 = 2 remainder 15 (F). Result:
2F₁₆.
A useful shortcut: since 2³ = 8 and 2⁴ = 16, you can convert directly between binary, octal, and hex by grouping bits:
- Binary ↔ Octal: Group bits in threes from the right.
110 101→6 5→65₈ - Binary ↔ Hex: Group bits in fours from the right.
1100 1101→C D→CD₁₆
Binary arithmetic rules
Binary addition uses only four basic rules:
Subtraction follows the same principle in reverse, borrowing from the next higher bit when needed. Multiplication is repeated addition; division is repeated subtraction or the standard long-division algorithm applied in base 2.
Practical applications
- RGB color codes. Web colors like
#FF8C00are three hexadecimal bytes (R=255, G=140, B=0). Understanding hex to decimal conversion is essential for CSS, canvas APIs, and image processing. - IPv4 addresses. Each octet of an IP address is one byte (0–255). The subnet mask
255.255.255.0is11111111.11111111.11111111.00000000in binary. - Bitwise operations. Languages like C, Java, and JavaScript provide AND (
&), OR (|), XOR (^), and bit-shift operators that work directly on binary representations. - File permissions. Unix-style permissions (read=4, write=2, execute=1) are directly representable in octal —
chmod 644meansrw-r--r--in binary bit fields.
How to use this calculator
Arithmetic mode lets you choose an operator (+, −, ×, ÷) and enter two numbers each in any base. Results appear instantly in all four bases. Click any result card to jump to Convert mode for further exploration.
Convert mode takes a single number in any base and displays its equivalent in binary, decimal, hexadecimal, and octal simultaneously. For values 0–255, it also shows an 8-bit positional table and the active powers of 2 that sum to the input value.
Limitations
This calculator works with non-negative integers. JavaScript represents integers exactly up to 2⁵³ − 1 = 9,007,199,254,740,991. Results beyond the 32-bit unsigned range (greater than 4,294,967,295) are displayed with a warning. For negative-number representation, two's complement is the standard in digital systems — see our editorial above for the explanation.