Binary, Decimal, Hexadecimal: Converting Between Number Systems
Understand binary, decimal, and hexadecimal number systems. Why they matter in computing and how to convert between them.
Why Computers Use Binary
Computers are built from transistors that have two states: on (1) and off (0). All computing is fundamentally binary — combinations of 1s and 0s. Higher-level number systems (decimal, hexadecimal) are human-readable representations of this binary data.
The Three Number Systems
Decimal (base 10): What humans use. Digits 0-9. Each position is a power of 10.
Binary (base 2): Computers use. Digits 0 and 1 only. Each position is a power of 2.
Hexadecimal (base 16): Compact representation of binary. Digits 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.
Converting Decimal to Binary
Divide the decimal number repeatedly by 2 and read remainders from 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
Read remainders bottom to top: 101010. So 42 in decimal = 101010 in binary.
Converting Binary to Decimal
Multiply each bit by its position value (powers of 2 from right) and sum.
Example: 1011 in binary
= (1×8) + (0×4) + (1×2) + (1×1)
= 8 + 0 + 2 + 1
= 11 in decimal
Hexadecimal in Practice
Color codes: #FF5733 = FF(255) red, 57(87) green, 33(51) blue.
Memory addresses: 0x7FFEE4B72C8 in x86 assembly.
IPv6: 2001:0db8:85a3:0000 — groups of 4 hex digits.
ASCII: Character codes expressed in hex (A = 0x41 = 65 decimal).
Frequently asked questions
Why do computers use binary?
Computers use transistors with two states (on/off, 1/0). Binary maps directly to these physical states. Decimal would require 10 distinct electrical states per digit, which is impractical to implement reliably in hardware.
Put this guide into practice with our free online tool — no signup required.
Open tool