Binary, Decimal, Hex, and Octal: Number System Conversion Guide
Convert between binary, decimal, hexadecimal, and octal number systems with step-by-step examples.
Why Number Systems Matter
Computers think in binary (base 2). Humans think in decimal (base 10). Programmers use hexadecimal (base 16) as a shorthand for binary. Older systems used octal (base 8). Understanding conversions between them is fundamental to computer science, networking, and programming.
The Four Number Systems
| System | Base | Digits Used | Prefix |
|---|---|---|---|
| Binary | 2 | 0, 1 | 0b (e.g. 0b1101) |
| Octal | 8 | 0-7 | 0o (e.g. 0o17) |
| Decimal | 10 | 0-9 | None |
| Hexadecimal | 16 | 0-9, A-F | 0x (e.g. 0xFF) |
In hexadecimal: A=10, B=11, C=12, D=13, E=14, F=15
Decimal to Binary Conversion
Divide the number by 2 repeatedly, recording remainders. Read remainders bottom to top.
Example: 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
Reading remainders bottom to top: 101010
42 in decimal = 101010 in binary
Verification: 1×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1 = 32+8+2 = 42 ✓
Binary to Decimal Conversion
Multiply each bit by its positional value (powers of 2) and sum.
Example: Convert 11001 to decimal:
Position values (right to left): 1, 2, 4, 8, 16
1×16 + 1×8 + 0×4 + 0×2 + 1×1 = 16+8+1 = 25
Decimal to Hexadecimal
Divide by 16 repeatedly.
Example: Convert 255 to hexadecimal:
255 ÷ 16 = 15 remainder 15 (F)
15 ÷ 16 = 0 remainder 15 (F)
Reading bottom to top: FF
255 decimal = FF hexadecimal
Common hex values to memorise:
- 255 = FF (maximum value of one byte)
- 256 = 100
- 16 = 10
- 0 = 00
Hexadecimal to Decimal
Multiply each digit by its positional value (powers of 16) and sum.
Example: Convert 2A to decimal:
2×16 + 10×1 = 32+10 = 42
Example: Convert FF to decimal:
15×16 + 15×1 = 240+15 = 255
Binary to Hexadecimal (The Shortcut)
Group binary digits in sets of 4 from right. Convert each group to its hex equivalent.
Example: Convert 10111110 to hexadecimal:
Group: 1011 | 1110
1011 = 11 = B
1110 = 14 = E
10111110 binary = BE hexadecimal
Hex-to-binary reverse: Expand each hex digit to 4 binary digits.
Why Hexadecimal Is Used in Programming
Hex is compact shorthand for binary. One hex digit represents exactly 4 binary bits. Two hex digits represent one byte (8 bits). This makes memory addresses, colour codes, and error codes readable.
Web colours: #FF5733 means R=FF(255), G=57(87), B=33(51) in decimal.
Memory: 0xFFFFFFFF is the 32-bit maximum address.
ASCII: Character 'A' is 65 decimal = 41 hex = 01000001 binary.
Using Lazyblink Binary Translator
lazyblink.com/tools/developer/binary-translator converts between all four number systems instantly. Paste any number, select the source base, and see all four conversions simultaneously. Useful for programming, networking tasks, and computer science students.
Frequently asked questions
How do I convert decimal to binary?
Divide the decimal number by 2 repeatedly, recording the remainder each time. Read the remainders from bottom to top to get the binary number. Example: 42 = 101010 in binary.
What is hexadecimal used for in programming?
Hexadecimal is used for memory addresses, colour codes (#RRGGBB in web), error codes, and as a compact representation of binary data. Two hex digits represent one byte, making it more readable than raw binary.
How do I convert binary to hexadecimal?
Group binary digits into sets of 4 from right to left. Convert each group to its hex equivalent. Example: 10111110 groups as 1011 and 1110, which converts to B and E, giving BE in hexadecimal.
Put this guide into practice with our free online tool — no signup required.
Open tool