Base Converter
Binary, octal, decimal, hex
About This Calculator
Number base conversion translates a number from one numeral system to another. Binary (base 2) is used by computers, octal (base 8) in file permissions, hexadecimal (base 16) in color codes and memory addresses, and decimal (base 10) in everyday use.
Formula
To decimal: multiply each digit by base^position and sum
From decimal: repeatedly divide by target base, read remainders upward
Hex shortcut: each hex digit = 4 binary bits (nibble)
Example Calculation
Convert 255 decimal to binary, hex, and octal
- 255 / 2 repeatedly: 11111111 binary
- 255 / 16 = 15 rem 15 = FF hex
- 255 / 8 repeatedly: 377 octal
255 decimal = 11111111 binary = FF hex = 377 octal
Decimal 0-15 in Binary, Octal, and Hex
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
Frequently Asked Questions
Why do computers use binary?
Computer hardware represents data with two electrical states (on/off, high/low voltage), making binary the natural number system. Every number, text character, image, and instruction is ultimately stored as a sequence of 0s and 1s.
What is hexadecimal used for in programming?
Hex is used for memory addresses, color codes (#FF5733), byte values, and binary data because each hex digit maps to exactly 4 binary bits, making long binary strings much more readable.
How do I convert binary to hex quickly?
Group binary digits into groups of 4 from the right, then convert each group to one hex digit. For example, 11011010 = 1101 1010 = D A = DA in hex.
What does 0x mean before a number?
The 0x prefix denotes a hexadecimal number in programming (e.g. 0xFF = 255). Similarly, 0b means binary (0b1010 = 10) and 0o or 0 means octal in various languages.