Binary, octal and hexadecimal are just different ways of writing the same numbers. Understanding positional bases makes sense of memory addresses, file permissions, colour codes and bit flags. This guide shows how the bases work and how to convert between them by hand.
How positional bases work
In any base b, each digit position represents a power of b, starting at b to the power 0 on the right. Decimal, or base 10, uses powers of 10; binary, or base 2, uses powers of 2; octal uses 8; hexadecimal uses 16. Hexadecimal needs sixteen symbols, so it uses 0 to 9 and then A=10, B=11 up to F=15. The number 2, for example, is written 10 in binary, 2 in octal and 2 in hex — while decimal 255 is FF in hex and 11111111 in binary.
Converting by hand
To convert from another base to decimal, multiply each digit by its place value and add. Binary 1011 is 1×8 + 0×4 + 1×2 + 1×1 = 11. Hex 2F is 2×16 + 15×1 = 47. To go the other way, divide by the base and record the remainders: decimal 13 in binary is 1101, because 13 ÷ 2 leaves remainders 1, 0, 1, 1 read bottom to top.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 255 | 11111111 | 377 | FF |
Notice that one hex digit equals exactly four binary bits, and one octal digit equals three bits. That alignment is why programmers use hex and octal as compact shorthand for binary — converting 11111111 by eye is easy once you group it into nibbles.
Why programmers rely on it
A byte holds eight bits, which is exactly two hex digits, so hex is the natural notation for raw memory, hashes and machine code. Octal appears in Unix file permissions, where rwxrwxrwx maps to 777. Bit flags for feature toggles are set with shifts like 1 << 3, which read far more clearly in binary or hex than in decimal. Convert any value with the Number Base Converter to check your hand calculations.
Hex colours and byte values
Web colour codes are hexadecimal RGB values. The code #FF8000 means red = FF = 255, green = 80 = 128, blue = 00 = 0, giving a warm orange. Each channel runs from 0 to 255, which is exactly the range of one unsigned byte. Understanding this link between hex, bytes and colour makes it easy to tweak a palette, and the Color Converter translates between hex, RGB and other formats instantly.
Frequently asked questions
Why is hex used instead of binary? Because four binary bits fit neatly into one hex digit, so hex is shorter to write and read while mapping directly to bits.
What is 0x in a number? It is a prefix meaning the following digits are hexadecimal — 0xFF is hexadecimal 255.
Do computers actually store octal? Not directly; octal is a human shorthand for groups of three bits, still common for Unix permissions.