Calcist

Style

Buttons

Spacing

How much to show

Decimal places

Text size

Binary, decimal and hexadecimal

Decimal, binary and hexadecimal are three ways of writing the same numbers. We count in tens, computers store everything in twos, and programmers use hex as a short way to write binary.

By the Calcist team · Updated October 26, 2026 · About a 5-minute read

Place value is the whole idea

In decimal, each place is worth 10 times the one to its right: 255 = 2×100 + 5×10 + 5×1. Binary works the same way with 2: each place is worth 1, 2, 4, 8, 16 and so on, and the only digits are 0 and 1. Hexadecimal uses 16, with digits 0–9 and then A–F for 10–15.

DecimalBinaryHex
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
101010A
111011B
121100C
131101D
141110E
151111F

Binary to decimal

Add up the place values that have a 1. 1101 = 8 + 4 + 0 + 1 = 13. 11111111 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.

Decimal to binary

Divide by 2 again and again, writing down the remainders, then read them from the bottom up. For 13: 13 ÷ 2 = 6 r 1, 6 ÷ 2 = 3 r 0, 3 ÷ 2 = 1 r 1, 1 ÷ 2 = 0 r 1. Reading upward gives 1101.

Binary to hex, and back

This is why programmers love hex: every hex digit is exactly four binary digits. Split the binary into groups of four from the right and swap each group using the table. 1111 1111 = FF. 0010 1010 = 2A, which is 42 in decimal. To go back, write each hex digit as four bits: 3C = 0011 1100.

Negative numbers: two's complement

Computers usually store negative whole numbers in two's complement. To get −x in 8 bits, flip every bit of x and add 1. 5 is 0000 0101; flipped it's 1111 1010; add 1 and −5 is 1111 1011 (FB in hex). The top bit tells you the sign, so 8 bits hold −128 to 127 signed, or 0 to 255 unsigned. When a sum goes past the end it wraps around: in 8-bit signed, 127 + 1 = −128.

Try it

The programmer calculator converts between all four bases at once, shows every bit, does AND, OR, XOR, NOT and shifts, and lets you pick 8, 16, 32 or 64 bits, signed or unsigned.

Every worked example on this page was checked with Calcist's own engine and an independent reference.

Questions people ask

How do I convert binary to decimal?

Add the place values (1, 2, 4, 8, 16…) wherever there is a 1. 1101 = 8 + 4 + 1 = 13.

What is 255 in hex?

FF. In binary it's 1111 1111.

Why do programmers use hexadecimal?

Each hex digit is exactly four binary digits, so a long binary number is much shorter and easier to read in hex.

What is two's complement?

The usual way computers store negative whole numbers: flip all the bits of the positive number and add 1. In 8 bits, −5 is 1111 1011.