Back to Blog
DeveloperFebruary 4, 202610 min read
Number Base Conversion: Binary, Octal, Decimal, and Hexadecimal
Master number system conversions with clear explanations and examples. Learn to convert between binary, octal, decimal, and hexadecimal with ease.
What Are Number Bases?
A number base (or radix) determines how many unique digits are used to represent numbers. The decimal system we use daily is base-10, using digits 0 through 9. Computers use binary (base-2), and programmers frequently work with octal (base-8) and hexadecimal (base-16).
The Four Common Bases
| Base | Name | Digits Used | Common Use |
|---|---|---|---|
| Base 2 | Binary | 0, 1 | Computer hardware, bitwise operations |
| Base 8 | Octal | 0-7 | Unix file permissions (chmod) |
| Base 10 | Decimal | 0-9 | Everyday numbers |
| Base 16 | Hexadecimal | 0-9, A-F | Colors (#FF0000), memory addresses |
Conversion Examples
Decimal 42 in different bases:
Binary: 101010
Octal: 52
Hexadecimal: 2A
Decimal 255:
Binary: 11111111
Octal: 377
Hexadecimal: FF
Decimal 100:
Binary: 1100100
Octal: 144
Hexadecimal: 64How to Convert Decimal to Binary
Divide the decimal number by 2 repeatedly. Write down each remainder. Read the remainders from bottom to top.
Convert 42 to binary:
42 / 2 = 21 remainder 0
21 / 2 = 10 remainder 1
10 / 2 = 5 remainder 0
5 / 2 = 2 remainder 1
2 / 2 = 1 remainder 0
1 / 2 = 0 remainder 1
Read bottom to top: 101010How to Convert Binary to Decimal
Multiply each digit by its position value (powers of 2) and add them up.
Convert 101010 to decimal:
1 x 32 = 32
0 x 16 = 0
1 x 8 = 8
0 x 4 = 0
1 x 2 = 2
0 x 1 = 0
Total: 42Where Developers Use These
- Binary: Understanding bitwise operators (&, |, ^, ~) in any programming language
- Octal: Linux file permissions (chmod 755 is octal for rwxr-xr-x)
- Hexadecimal: CSS colors (#FF5733), memory addresses, debugging
- All bases: Working with low-level code, networking, embedded systems
Free Number Base Converter
Convert between binary, octal, decimal, and hexadecimal instantly.
Try it free