Number base conversion is the process of expressing the same number in different positional numeral systems. While humans use base 10 (decimal), computers use base 2 (binary) internally, and programmers frequently work with base 16 (hexadecimal) and base 8 (octal).
The four common bases
| Base | Name | Digits used | Example |
|---|---|---|---|
| 2 | Binary | 0, 1 | 1010 |
| 8 | Octal | 0–7 | 12 |
| 10 | Decimal | 0–9 | 10 |
| 16 | Hexadecimal | 0–9, A–F | A |
All four represent the same number: ten.
Why hexadecimal?
Hex compresses binary: each hex digit represents exactly 4 binary bits. A byte (8 bits) is always 2 hex digits. This makes hex much easier to read than raw binary for memory addresses, color codes, and binary file formats.
Binary: 1111 1010
Hex: FA
Decimal: 250
Common uses by base
- Binary — CPU registers, bitwise operations, network masks
- Octal — Unix file permissions (
chmod 755,chmod 644) - Decimal — All everyday numbers, IP addresses
- Hexadecimal — Colors (
#FF5733), memory addresses (0x7FFE), character codes, MAC addresses
Quick reference: 0–15
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
Two's complement for negative numbers
Computers represent negative numbers using two's complement in binary. For an 8-bit signed integer, -1 is 11111111 (255 unsigned). This is why parseInt('FF', 16) gives 255 in JavaScript, but the same byte in a signed context is -1.
How to convert number bases online
- Go to Number Base Converter
- Enter a number in any base field (binary, octal, decimal, or hex)
- All other fields update instantly
- See 8-bit, 16-bit, and 32-bit representations below