There are four number systems you will encounter in computing: binary (base-2), octal (base-8), decimal (base-10), and hexadecimal (base-16). They all represent the same values — just written differently. 255 in decimal = 11111111 in binary = FF in hex = 377 in octal.
If you have ever wondered why programmers write FF instead of 255, why Linux permissions use numbers like 755, or why computers "think" in 1s and 0s — this guide explains all four number systems from scratch. No math background required.
This is the table you will keep coming back to. Key values shown in all four bases side by side:
| Decimal | Binary | Hex | Octal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 8 | 10 |
| 10 | 1010 | A | 12 |
| 15 | 1111 | F | 17 |
| 16 | 10000 | 10 | 20 |
| 31 | 11111 | 1F | 37 |
| 32 | 100000 | 20 | 40 |
| 63 | 111111 | 3F | 77 |
| 64 | 1000000 | 40 | 100 |
| 127 | 1111111 | 7F | 177 |
| 128 | 10000000 | 80 | 200 |
| 255 | 11111111 | FF | 377 |
| 256 | 100000000 | 100 | 400 |
| 512 | 1000000000 | 200 | 1000 |
| 1024 | 10000000000 | 400 | 2000 |
| 65535 | 1111111111111111 | FFFF | 177777 |
| Property | Binary (Base-2) | Octal (Base-8) | Decimal (Base-10) | Hex (Base-16) |
|---|---|---|---|---|
| Digits used | 0, 1 | 0-7 | 0-9 | 0-9, A-F |
| Why it exists | Matches transistor on/off states | Groups of 3 bits for permissions | Human counting (10 fingers) | Compact representation of binary |
| Common uses | Hardware, bitwise operations, flags | Unix file permissions (chmod) | Everyday math, human-readable values | Colors, memory addresses, hashes |
| Bits per digit | 1 | 3 | ~3.32 | 4 |
| How to spot it | Starts with 0b (programming) | Starts with 0o (Python) or 0 (C) | No prefix (default) | Starts with 0x or # (colors) |
| Compactness | ✗ Very long | ~Moderate | ~Moderate | ✓ Most compact |
| Human readable | ✗ Hard to read | ~Moderate | ✓ Easiest | ~Takes practice |
Binary is base-2 — it uses only two digits: 0 and 1. Every piece of data in every computer on Earth is ultimately stored in binary.
Why? Because computer hardware is built from transistors, and transistors are switches with two states: on (1) and off (0). There is no "sort of on." This two-state design makes circuits simpler, faster, and more reliable.
Binary is verbose — the number 255 requires 8 digits (11111111) instead of 3. That is why humans rarely work directly in binary. We use hex or decimal as a more readable shorthand.
Where you see binary:
Octal is base-8 — it uses digits 0 through 7. Each octal digit represents exactly 3 binary bits, which aligns perfectly with Unix file permission groups.
The command chmod 755 myfile uses three octal digits:
| Permission | Binary | Octal | Meaning |
|---|---|---|---|
| --- | 000 | 0 | No permissions |
| --x | 001 | 1 | Execute only |
| -w- | 010 | 2 | Write only |
| -wx | 011 | 3 | Write + execute |
| r-- | 100 | 4 | Read only |
| r-x | 101 | 5 | Read + execute |
| rw- | 110 | 6 | Read + write |
| rwx | 111 | 7 | Read + write + execute |
This is why octal survives in modern computing — it is the perfect fit for the 3-bit permission model. Beyond file permissions, octal is rare in everyday programming.
Hexadecimal is base-16 — it uses digits 0-9 plus letters A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Each hex digit represents exactly 4 binary bits, which means one byte (8 bits) is always exactly 2 hex digits.
This 4-bit mapping is what makes hex so useful. Instead of writing the 32-bit binary number 11001010111111101011101011111110, you write CAFEBABE — 8 characters instead of 32. Same value, much easier to read, type, and remember.
Where you see hex everywhere:
The simplest approach is the decimal bridge method: convert from the source base to decimal, then from decimal to the target base.
Multiply each digit by the base raised to its position (starting at 0 from the right), then add them all together.
Example: Octal 377 to decimal
192 + 56 + 7 = 255
Repeatedly divide by the target base and collect the remainders. Read remainders from bottom to top.
Example: Decimal 255 to hex
Reading bottom to top: FF
Group binary digits into sets of 4 from the right. Convert each group to its hex digit. No decimal bridge needed.
Example: Binary 11001010 to hex
Result: CA
Group binary digits into sets of 3 from the right. Convert each group to its octal digit.
Example: Binary 11111111 to octal
Result: 377
| Use Case | Base Used | Why This Base | Example |
|---|---|---|---|
| CSS colors | Hex | 2 digits per color channel, compact | #FF5733 |
| File permissions | Octal | 3 bits per permission group | chmod 755 |
| IP addresses | Decimal (stored in binary) | Human-readable for network config | 192.168.1.1 |
| Memory addresses | Hex | Compact representation of 64-bit addresses | 0x7FFF5FBFF8A0 |
| MAC addresses | Hex | 6 bytes displayed as 12 hex digits | AA:BB:CC:DD:EE:FF |
| Price tags | Decimal | Everyday human readability | $29.99 |
| Subnet masks | Binary / Decimal | Shows the exact bit boundary | 255.255.255.0 = /24 |
| Hash values | Hex | Compact display of large binary outputs | d41d8cd98f00b204... |
| Unicode code points | Hex | Range 0-10FFFF is cleaner in hex | U+0041 = A |
| Bit flags | Binary | Each bit is a separate on/off flag | 10110 = features 1,2,4 on |
Enter a number in any base — binary, octal, decimal, or hex — and see all conversions instantly.
Open Number Base Converter