Binary vs Hexadecimal vs Decimal: Number System Comparison
Binary, hexadecimal, and decimal are three positional number systems used in computing, and the only thing that separates them is the base – how many digit symbols each one has. Decimal is base 10 (0-9), binary is base 2 (0 and 1), and hexadecimal is base 16 (0-9 then A-F). This guide defines all three, shows how to convert between them, and explains why hex exists at all.
What Is the Difference Between Decimal, Binary, and Hexadecimal?
The difference is the base: how many symbols each system uses before it carries to the next place. Every system is positional – each place is the base raised to a power:
Decimal , base 10
Binary , base 2
Hexadecimal , base 16
What Is the Decimal Number System?
The decimal system is a base-10 positional system that uses ten digits, 0 through 9, with each position worth a power of 10:
- Place values: ones (10⁰), tens (10¹), hundreds (10²), thousands (10³), and so on.
- Worked example: in 3,742 the value is 3×1,000 + 7×100 + 4×10 + 2×1 = 3,742.
- Where it lives: human arithmetic and the user interface only – no computer computes internally in decimal; the hardware converts to binary first.
What Is the Binary Number System?
The binary system is a base-2 positional system that uses just two digits, 0 and 1 (each one a “bit”), with each position worth a power of 2:
- Why two: a transistor has exactly two stable states, so 0/1 maps straight onto off/on (low/high voltage).
- Worked example: binary 1011 = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11 decimal.
- The catch: binary gets long fast – 255 needs 8 bits (11111111) and 65,535 needs 16 bits, which is painful for a human to read.
What Is the Hexadecimal Number System?
The hexadecimal system is a base-16 positional system that uses sixteen symbols: 0-9 and A-F, where A=10, B=11, C=12, D=13, E=14, F=15:
- The key trick: 16 is a power of two (16 = 2⁴), so one hex digit equals exactly four bits (a “nibble”).
- Bytes line up: 8-bit bytes become exactly 2 hex digits, and 32-bit values become exactly 8 hex digits – no leftover bits.
- Worked example: hex FF = 15×16 + 15 = 255 decimal = 11111111 binary. Two hex characters replace eight binary digits.
Why Do Programmers Use Hexadecimal?
Programmers use hex because it is a compact, error-resistant shorthand that still maps cleanly back to binary – which decimal does not:
- Shorter: a 32-bit value is 8 hex characters instead of 32 binary digits.
- Aligned to binary: each hex digit is one fixed 4-bit group, so you can convert by eye – no division. Decimal digits do not line up with bit boundaries.
- Easier to scan: a 2-digit byte pair like 0x4C is far harder to misread than 01001100.
Where Is Hexadecimal Used in Computing?
Hexadecimal shows up anywhere humans need to read raw binary data. Five everyday places:
Web color codes
Memory addresses
MAC addresses
Cryptographic hashes
Machine code / assembly
How Do You Convert Between Binary and Hexadecimal?
Converting between binary and hex is pure grouping – no arithmetic, because each hex digit is a fixed 4-bit pattern:

- Binary to hex: split the bits into groups of 4 from the right (pad the left with 0s), then map each group to one hex digit.
- Example: 10111100 splits into 1011 | 1100 = B | C = 0xBC.
- Hex to binary: expand each hex digit back into its 4 bits. 0xAF -> A=1010, F=1111 -> 10101111.
How Do You Convert Hexadecimal and Decimal?
Converting to and from decimal uses place values (powers of the base) one way and repeated division the other:
- Hex to decimal: multiply each digit by its power of 16 and add. 0x1F4 = 1×256 + 15×16 + 4×1 = 500.
- Decimal to hex: divide by 16 repeatedly and read the remainders bottom to top (as hex digits).
Decimal to hex, step by step (255):
- 255 ÷ 16 = 15 remainder 15 (F)
- 15 ÷ 16 = 0 remainder 15 (F)
- Read remainders bottom to top: 255 decimal = 0xFF.
What Is the Octal Number System?
Octal is a base-8 system using digits 0-7, where each octal digit equals three bits:
- How it groups: bits in sets of 3 (8 = 2³), the same idea as hex but with smaller groups.
- Where it survives: Unix file permissions (e.g. chmod 755) and 1960s-70s PDP and CDC mainframes.
- Today: modern computing uses hexadecimal almost exclusively as the human-readable shorthand for binary.
Number System Comparison Table
The table lines up the same values across decimal, binary, octal, and hexadecimal so the grouping pattern is visible:
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 00010000 | 20 | 10 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
| 65535 | 1111111111111111 | 177777 | FFFF |
Where Each Number System Is Used in Programming
In day-to-day code the three systems split into clear roles:

- Decimal: user-facing values, money, array indices, loop counters. Default literals in Python, JavaScript, C, and Java.
- Binary: bitwise operations, flag masks, subnet math. Literals: 0b1010 (Python/C), 0B1010 (Java).
- Hexadecimal: memory addresses, color values, byte inspection, crypto output, hardware registers. Literals: 0xFF (C/Python/Java), #FF0000 (CSS).
Last Thoughts on Binary vs Hexadecimal vs Decimal
Decimal, binary, and hexadecimal are not competing systems – they serve complementary roles. Binary is mandatory at the hardware level, decimal is mandatory at the human interface level, and hexadecimal bridges the two by giving programmers a compact, readable stand-in for binary that they use daily for memory addresses, color codes, network IDs, and cryptographic values.
Key Takeaways:
- Decimal (base 10) uses digits 0–9 and is the default for human arithmetic and user-facing outputs.
- Binary (base 2) uses digits 0–1 and is the native system of all digital hardware.
- Hexadecimal (base 16) uses digits 0–9 and A–F; 1 hex digit = 4 binary bits.
- Hex shortens binary representation: the byte 11111111 binary = FF hex (2 characters vs 8).
- Hex is used in memory addresses, RGB color codes, MAC addresses, and SHA hashes.
- Octal (base 8) is a legacy system still found in Unix file permission notation (chmod).
Frequently Asked Questions (FAQs)
Why do programmers use hexadecimal instead of binary?
Hexadecimal is a compact shorthand for binary. Each hex digit represents exactly 4 bits, so a 32-bit value needs 8 hex characters instead of 32 binary digits. Hex is easier to read, write, and memorize than raw binary.
What is 0xFF in decimal?
0xFF = 15×16 + 15 = 255 decimal. In binary it is 11111111 — the maximum value of one unsigned byte. In CSS, #FF0000 is pure red at full intensity.
What does the 0x prefix mean?
The 0x prefix indicates a hexadecimal literal in most programming languages (C, Python, Java, JavaScript). For example, 0x1F = 31 decimal. It prevents confusion with decimal numbers.
How do you convert hex to binary?
Expand each hex digit to 4 binary bits. Example: 0xB3 → B = 1011, 3 = 0011 → 10110011 binary. No arithmetic is needed — each hex digit maps directly to a 4-bit group.
What is the difference between decimal and binary 10?
Decimal 10 = ten. Binary 10 = 2 decimal (1×2¹ + 0×2⁰). Context (or a prefix like 0b for binary) determines which system applies. Without context, “10” is assumed decimal.


