The same number can be written in any base — base 10 is simply the one humans use by convention. Programming regularly requires the others: binary for bit manipulation and flags, hexadecimal for colours, memory addresses and byte values, octal for Unix file permissions.
How to use the Number Base Converter
- Type a number into the field for the base you are starting from
- The other bases update immediately
- Copy whichever representation you need
Where each base shows up
- Binary (base 2) — bitmasks, permission flags, and anything where individual bits carry meaning.
- Octal (base 8) — Unix file permissions.
chmod 755is octal: each digit is three permission bits, so 7 is rwx and 5 is r-x. - Decimal (base 10) — everything people read.
- Hexadecimal (base 16) — colours (
#7c6cff), memory addresses, byte values, and hashes. Popular because one hex digit maps to exactly four bits, so two digits are exactly one byte.
Converting by hand
Hex to binary is the easy direction, because each hex digit is exactly four binary digits. F is 1111, A is 1010, so FA is 11111010. No arithmetic required — just substitution.
To decimal, multiply each digit by its positional value. FA in hex is (15 × 16) + 10 = 250. From decimal, divide repeatedly by the target base and read the remainders backwards.
Worth memorising: hex FF is 255, the maximum value of one byte, which is why colour channels run 00–FF.
Reading hexadecimal in the wild
Hex turns up constantly once you recognise it, and knowing what each form represents saves a lot of lookups.
Colours. #7C6CFF is three bytes — red 0x7C (124), green 0x6C (108), blue 0xFF (255). Each pair runs 00 to FF, so FF is a fully saturated channel and 80 is roughly half.
Memory addresses. 0x7FFE0000. Hex is used because each digit maps to exactly four bits, so alignment boundaries are visible — an address ending in 000 is 4096-byte aligned at a glance.
Unicode code points. U+1F600 is the grinning face emoji. The U+ prefix always introduces hex.
File signatures. The first bytes of a file identify its type: 89 50 4E 47 is PNG, FF D8 FF is JPEG, 25 50 44 46 is %PDF.
Error codes. Windows 0x80070005 and similar pack several fields into one word, which is only legible in hex.
The useful conversion to memorise is that one hex digit is four bits, so two hex digits are exactly one byte and FF is 255.
Binary, bitmasks and file permissions
Binary is worth reading whenever individual bits carry separate meanings, which is the idea behind both Unix permissions and flag arguments.
Unix permissions are three octal digits because each digit is exactly three bits: read (4), write (2), execute (1). 755 is 111 101 101 — the owner may read, write and execute; group and others may read and execute. 644 is read-write for the owner and read-only for everyone else. 777 grants everything to everyone and is almost never the right answer. Octal is used here rather than hex precisely because three bits fit one digit.
Bitmask flags work the same way. A function taking READ | WRITE is combining values 1 and 2 with a bitwise OR to get 3, and the receiving code tests each bit separately. This is why flag constants are always powers of two — each occupies its own bit so none can collide.
Subnet masks are the same idea in four bytes. 255.255.255.0 is twenty-four one bits followed by eight zeros, which is why it is also written /24.
Frequently asked questions
Why is hexadecimal used so widely in programming?
Because one hex digit is exactly four bits, so two digits are exactly one byte. That makes the mapping between hex and binary direct and readable, which base 10 cannot offer.
What does chmod 755 mean?
It is octal. Each digit is three permission bits for owner, group and others: 7 is rwx (4+2+1), 5 is r-x (4+1). So the owner can read, write and execute; everyone else can read and execute.
Can it convert negative numbers?
It handles standard negative decimal input. Two's-complement representations — how negative numbers are actually stored in binary — depend on the word size and are not computed here.
What are the 0x and 0b prefixes?
Conventions marking the base in source code: 0x for hexadecimal, 0b for binary, and a leading 0 for octal in many languages. They are notation, not part of the number.