gg
HomeBlog › Decimal, Binary, Octal, Hex: One Number, Four Notations

Decimal, Binary, Octal, Hex: One Number, Four Notations

2026-09-22 · 3 min read
conversionsunitsmathdevdiy

A byte's max value is written 255 in decimal, FF in hex, 377 in octal, and 11111111 in binary. None of those is more "correct" than the others — a number doesn't change when you change how you write it, the same way 12 inches and 1 foot are the same length in two notations. This tool converts a whole number between decimal, binary, octal and hexadecimal, and the method behind every one of those conversions is the same idea: place value, just with a different base.

The method: place value in any base

In decimal, the digits of 492 mean 4×100 + 9×10 + 2×1 — each position is worth ten times the one to its right, because decimal is base 10. Binary works identically but each position is worth two times the one to its right (base 2); octal, eight times (base 8); hex, sixteen times (base 16). To read a number in any base, multiply each digit by its position's place value (a power of the base) and add them up. To go the other way — decimal into some other base — repeatedly divide by the target base and read the remainders from last to first.

A worked example: 255, in all four bases

255 is a byte's maximum value: 2 to the 8th power is 256, so 255 is one less. In binary: 255 = 128+64+32+16+8+4+2+1, which is every power of two from 1 up to 128 added once — written as eight 1s, 11111111. In octal, group those eight bits into 3s from the right (padding a leading zero to make 9 bits: 011 111 111): 011=3, 111=7, 111=7, giving 377. In hex, group into 4s instead (1111 1111): 1111=15=F, 1111=15=F, giving FF. All three — 11111111, 377, FF — are the same number as decimal 255.

A second example: 192, an IP address octet

Every number in an IPv4 address like 192.168.1.1 is a single byte (0–255). Take the first one, 192: in binary, 192 = 128+64, so only the top two bits are set and the rest are 0: 11000000. Grouping those bits into 3s from the right for octal (011 000 000): 3, 0, 0, giving 300. Grouping into 4s for hex (1100 0000): 12=C, 0=0, giving C0. A network engineer reading "192.168.1.1" as C0.A8.01.01 in hex is doing exactly this conversion, one octet at a time.

A third example: chmod 754, a Unix permission

Unix file permissions are usually typed in octal, like chmod 754 file.txt, because each octal digit maps to exactly 3 bits — one for read, one for write, one for execute. Reading 754 in binary by expanding each digit to 3 bits: 7=111, 5=101, 4=100, giving 111101100 — read as three groups, owner rwx (111), group r-x (101), others r-- (100). In decimal: 7×64 + 5×8 + 4×1 = 448+40+4 = 492. That's the same number three ways — a decimal integer, a 9-bit permission mask, and the octal shorthand nobody has to expand by hand because the digit-to-3-bit mapping is fixed.

A fourth example: hex back to decimal

Going the reverse direction from hex: 2A. Reading right to left, A (which is 10) sits in the ones place and 2 sits in the sixteens place: 10×1 + 2×16 = 10 + 32 = 42. That's the same place-value formula as the very first paragraph, just with base 16 instead of base 10.

What the tool adds

The place-value formula above is all you need, on paper, to convert any whole number between these four bases. The tool's job is just speed and fewer mistyped digits: type a value, pick which base you typed it in, and it shows all four representations at once, 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