Binary, Decimal, and Hex Conversion: A Developer's Quick Reference
Computers speak binary, humans use decimal, and developers often work in hex. Learn how to convert between all three number systems with formulas and examples.
Computers think in binary; humans think in decimal; developers often work in hexadecimal. Understanding how to convert between these number systems is a fundamental computer science skill that comes up in networking, debugging, and low-level programming.
Decimal (Base 10)
The number system we use daily. 10 symbols: 0โ9. Each position represents a power of 10. The number 347 = 3ร10ยฒ + 4ร10ยน + 7ร10โฐ = 300 + 40 + 7.
Binary (Base 2)
Only 2 symbols: 0 and 1. Each position is a power of 2. Binary 1010 = 1ร2ยณ + 0ร2ยฒ + 1ร2ยน + 0ร2โฐ = 8 + 0 + 2 + 0 = decimal 10.
Decimal to Binary: Divide by 2, record remainders, read in reverse.
13 รท 2 = 6 remainder 1 6 รท 2 = 3 remainder 0 3 รท 2 = 1 remainder 1 1 รท 2 = 0 remainder 1 Reading remainders bottom to top: 1101 (= 13 in decimal) โ
Hexadecimal (Base 16)
16 symbols: 0โ9 and AโF (A=10, B=11, C=12, D=13, E=14, F=15). Each hex digit represents exactly 4 binary digits (a nibble). This makes hex a compact human-readable representation of binary.
- 0xFF = 255 (11111111 in binary)
- 0x1A = 26 (1ร16 + 10 = 26)
- 0xFF5733 = RGB color (red=255, green=87, blue=51)
Where You See Each System
- Binary: File permissions (755 = rwxr-xr-x), bitwise operations, network masks
- Hex: Color codes, memory addresses, MAC addresses, hash values, Unicode code points
- Octal (base 8): Unix file permissions (chmod 755)
Convert between number systems with our Number Base Converter.