Skip to main content
Binary / Hex

Binary and Hex Calculator

Convert between binary, decimal, hexadecimal, and octal number systems.

Input base

Decimal (Base 10)
no prefix
255
Binary (Base 2)
0b
0b11111111
Hex (Base 16)
0x
0xFF
Octal (Base 8)
0o
0o377

Binary bit breakdown (8 bits)

1
1
1
1
1
1
1
12^0

How It Works

This binary calculator does two jobs in one place. First, it converts any whole number between the four number systems that matter in computing โ€” decimal (base 10), binary (base 2), hexadecimal (base 16) and octal (base 8). Second, it performs binary arithmetic and bitwise logic โ€” addition, subtraction, multiplication and the AND, OR and XOR operators โ€” showing both the binary result and its decimal and hexadecimal equivalents. It is built for computer science students, embedded and firmware engineers, web developers juggling colour codes, and anyone preparing for a coding interview or a digital electronics exam.

What a number base actually means

A number base (or radix) is simply how many distinct digits a system uses before it rolls over to the next column. Decimal uses ten digits, 0โ€“9; binary uses two, 0 and 1; octal uses eight, 0โ€“7; and hexadecimal uses sixteen, 0โ€“9 then Aโ€“F where A=10, B=11, C=12, D=13, E=14 and F=15. The value of a number is the sum of each digit multiplied by the base raised to its position, counting from zero on the right. So in binary the columns are powers of two โ€” 1, 2, 4, 8, 16, 32 and so on โ€” and the binary number 1011 means 1ร—2ยณ + 0ร—2ยฒ + 1ร—2ยน + 1ร—2โฐ = 8 + 0 + 2 + 1 = 11 in decimal. The same positional rule, with a different base, governs every system this tool handles.

Converting between bases

To decimal: multiply each digit by its place value (the base raised to the column index) and add the products, exactly as in the 1011 example above. From decimal: divide repeatedly by the target base and read the remainders from last to first. To turn 156 into binary, divide by 2 again and again: 156โ†’78 r0, 78โ†’39 r0, 39โ†’19 r1, 19โ†’9 r1, 9โ†’4 r1, 4โ†’2 r0, 2โ†’1 r0, 1โ†’0 r1. Reading the remainders bottom-up gives 10011100. Hexadecimal has a handy shortcut: every group of four binary bits maps to exactly one hex digit, so 1001 1100 reads straight off as 9C. Octal works the same way in groups of three bits. This calculator accepts a number in any one base and instantly shows it in all four, with a bit-by-bit breakdown so you can see which powers of two are switched on.

Worked example โ€” binary addition

Add 1010 and 0110 in base 2. Work right to left, carrying whenever a column reaches 2: column 0 is 0+0=0; column 1 is 1+1=10, so write 0 and carry 1; column 2 is 0+1 plus the carry 1 = 10 again, write 0 carry 1; column 3 is 1+0 plus the carry 1 = 10, write 0 carry 1, and the final carry becomes a new leading 1. The result is 10000. Check it in decimal: 1010 is 10, 0110 is 6, and 10 + 6 = 16, which is 10000 in binary. The arithmetic tab shows exactly this, including the decimal and hex form of the answer.

Tips and common mistakes

Always confirm a result by converting back to decimal โ€” it catches most slips instantly. When you do binary addition by hand, remember the carry rule is "carry at 2", not "carry at 10". Reading division remainders top-down instead of bottom-up is the single most frequent conversion error, so build the binary string from the last remainder upward. Mind leading zeros: 0011 and 11 are the same value, but a fixed bit-width (8-bit, 16-bit) matters when you are masking or working with hardware registers. Hexadecimal is case-insensitive here, so FF and ff are identical. Finally, this tool works with non-negative whole numbers up to 32 bits; it does not handle fractions, negative two's-complement values or numbers beyond that range, which keeps the conversions exact and unambiguous.

Frequently Asked Questions

Transistors have two states: on (1) or off (0). Binary is the natural language of electronics. All data โ€” text (ASCII/Unicode), images (RGB pixels), programs โ€” is ultimately represented as binary at the hardware level.

Part of Math Tools & Converters โ€” compare every related calculator in one place.