gg
Home › Blog › Converting numbers between decimal, binary, hex and octal

Converting numbers between decimal, binary, hex and octal

2026-10-04 · 2 min read
mathdevnumbers

A byte value shows up as 500 in one tool, 0x1F4 in another and 764 somewhere else, and all three are the same number. Decimal (base 10), binary (base 2), octal (base 8) and hexadecimal (base 16) are just different counting systems for the same quantity — the digit count changes, the value doesn't.

The method

To go FROM decimal TO another base: repeatedly divide by the target base, write down the remainder each time, then read the remainders bottom-to-top. To go FROM another base TO decimal: multiply each digit by the base raised to its position (counting from 0 on the right) and add them up.

A real example: decimal 500 to binary

Divide by 2 repeatedly and keep the remainders: 500÷2=250 r0, 250÷2=125 r0, 125÷2=62 r1, 62÷2=31 r0, 31÷2=15 r1, 15÷2=7 r1, 7÷2=3 r1, 3÷2=1 r1, 1÷2=0 r1. Reading the remainders bottom-to-top gives 111110100. Check it: 256+128+64+32+16+4 = 500 — matches.

A real example: decimal 500 to hexadecimal

Same process, divide by 16: 500÷16=31 r4, 31÷16=1 r15 (15 is digit F), 1÷16=0 r1. Reading bottom-to-top: 1, F, 4, so 500 in hex is 0x1F4. Octal, by the same division with base 8, gives 0o764 — and all three (111110100, 1F4, 764) are the identical value 500.

A real example: hex 0xFF00 back to decimal

Each digit is multiplied by 16 raised to its position, counting from 0 at the rightmost digit. 0xFF00 has digits F, F, 0, 0 at positions 3, 2, 1, 0: (15 × 16^3) + (15 × 16^2) + (0 × 16^1) + (0 × 16^0) = (15 × 4096) + (15 × 256) + 0 + 0 = 61,440 + 3,840 = 65,280. So 0xFF00 is 65,280 in decimal.

Why hex and octal exist at all

Binary is what the hardware actually stores, but a byte in binary is 8 digits long and error-prone to read by eye. Hex groups binary cleanly because 16 is a power of 2 (one hex digit = exactly 4 bits), so 0x1F4 is far easier to scan than 111110100 while still mapping digit-for-digit onto the binary. Octal (one digit = 3 bits) served the same purpose on older systems built around 6-bit or 9-bit words and still turns up in Unix file permissions like chmod 764.

Run your own numbers

The free Number Base Converter converts a value between decimal, binary, octal and hexadecimal instantly, entirely on your device.

Try it free — with the steps shown

The Number Base Converter runs in your browser and shows exactly how it got the answer, so the method sticks.

Open Number Base Converter

More from the blog