Number Base Fundamentals
A number base (or radix) defines how many unique digits a counting system uses per position. The four bases most common in computer science:
- Binary (Base 2): Only 0 and 1 — the foundation of all computer hardware
- Octal (Base 8): Digits 0–7 — used for Unix file permissions
- Decimal (Base 10): Digits 0–9 — everyday human counting
- Hexadecimal (Base 16): Digits 0–9 plus A–F — memory addresses, color codes, hash values
Where Each Base Is Used
| Base | Prefix | Typical Applications |
| Binary | 0b | Bitwise operations, boolean logic, network subnet masks |
| Octal | 0o | Unix file permissions (chmod 755), legacy C literals |
| Decimal | none | User-facing numbers, everyday math |
| Hexadecimal | 0x | Memory addresses, color codes (#FF5733), hash values, byte sequences |
How Base Conversion Works
Decimal to Any Base
Divide repeatedly by the target base, reading remainders bottom-to-top:
10 (decimal) to binary:
10 ÷ 2 = 5 remainder 0
5 ÷ 2 = 2 remainder 1
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
Read bottom-up: 1010 (binary)
255 (decimal) to hex:
255 ÷ 16 = 15 remainder 15 → F
15 ÷ 16 = 0 remainder 15 → F
Result: FF
Any Base to Decimal
Multiply each digit by its positional power and sum:
1010 (binary) to decimal:
1×2³ + 0×2² + 1×2¹ + 0×2⁰ = 8 + 0 + 2 + 0 = 10
FF (hex) to decimal:
15×16¹ + 15×16⁰ = 240 + 15 = 255
How to Convert Number Bases Online
Use tool.tl's base converter:
- Go to tool.tl/base-converter
- Enter a number in any field (binary, octal, decimal, or hex)
- All other representations update in real time
- Supports any custom base from 2 to 36
Number Literals in Code
# Python
bin_val = 0b1010 # binary literal → 10
oct_val = 0o17 # octal literal → 15
hex_val = 0xFF # hex literal → 255
bin(255) # → '0b11111111'
hex(255) # → '0xff'
int('FF', 16) # → 255 (hex string to int)
// JavaScript
(255).toString(2) // → '11111111' (decimal to binary string)
(255).toString(16) // → 'ff'
parseInt('ff', 16) // → 255 (hex string to int)
Frequently Asked Questions
What do A–F represent in hexadecimal?
Hexadecimal (Base 16) needs 16 symbols, so after 0–9 it borrows letters: A=10, B=11, C=12, D=13, E=14, F=15. So 0xFF = 15×16 + 15 = 255. Case doesn't matter — 0xff and 0xFF are identical.
Why are color codes in hexadecimal?
Each RGB color channel ranges from 0–255 (one byte). Two hex digits (00–FF) represent exactly one byte, so 6 hex characters neatly encode all three channels. #FF5733 is more compact than rgb(255, 87, 51) for use in stylesheets and design tools.
Yes — tool.tl's base converter is completely free, converts in real time, supports bases 2–36, and requires no account.