Why programmers use hex
Each hexadecimal digit maps to exactly four binary digits, so hex is a compact, lossless shorthand for binary. The byte 11111111 is simply FF; converting by eye is a matter of splitting into nibbles.
Octal groups binary into threes and survives mainly in Unix file permissions, where 755 encodes three sets of three permission bits.
Converting by hand
To convert decimal to binary, repeatedly divide by two and record the remainders, then read them bottom to top. 13 divided by 2 gives 6 remainder 1, then 3 remainder 0, then 1 remainder 1, then 0 remainder 1 — reading upward gives 1101.
Going the other way, each binary digit represents a power of two. 1101 is 8 + 4 + 0 + 1 = 13. The same method works for any base: multiply each digit by the base raised to its position.
Where each base shows up
Binary is how hardware actually stores everything, but it is unreadable at length, which is why it rarely appears in source code directly. Hexadecimal is the practical compromise: colour codes, memory addresses, MAC addresses, hashes and byte dumps are all conventionally written in hex.
Octal is largely a historical survivor. Its most visible modern use is Unix file permissions, where chmod 755 encodes three groups of three permission bits — read, write and execute for owner, group and others.
Frequently asked questions
Does this handle very large numbers? +
Yes. Conversion uses arbitrary-precision integers, so values well beyond 64 bits stay exact rather than being rounded.
Why does hexadecimal use letters? +
Base 16 needs sixteen distinct digit symbols, but our numeral system only supplies ten. A through F fill the gap, representing the values ten through fifteen.
How many bits is a hex digit? +
Exactly four. That clean mapping is the whole reason hex is used as shorthand for binary — two hex digits make one byte.