Binary ↔ Decimal Conversion
Prepared for Intro to Computing
September 15, 2025
Learning goals
By the end of this tutorial, you will be able to:
• Explain positional notation in base-2 (binary) and base-10 (decimal).
• Convert binary integers to decimal using powers of two.
• Convert decimal integers to binary using repeated division by 2.
• (Optional) Convert fractional parts between binary and decimal.
• Check your work and avoid common mistakes.
1 Positional notation in a nutshell
A number in base b is a sum of digits times powers of b. For example, in decimal (base
10):
507 = 5 · 102 + 0 · 101 + 7 · 100 .
In binary (base 2), each digit is 0 or 1, and we use powers of 2:
11012 = 1 · 23 + 1 · 22 + 0 · 21 + 1 · 20 .
Note
Place values in binary (left to right):
· · · , 26 , 25 , 24 , 23 , 22 , 21 , 20 (binary point) 2−1 , 2−2 , . . .
2 Quick reference: powers of two
20 21 22 23 24 25 26 27 28 29
1 2 4 8 16 32 64 128 256 512
(You rarely need more than 20 to 29 for basic exercises.)
1
3 Binary → Decimal (integers)
Algorithm
Algorithm (Sum of powers of two).
1. Write the binary number. Label each bit with its power of 2 (rightmost bit is
20 ).
2. Keep only the powers where the bit is 1.
3. Add those powers to get the decimal value.
Example
Convert 11012 to decimal.
Bits (left to right): 1 1 0 1 at places 23 , 22 , 21 , 20 .
11012 = 1 · 23 + 1 · 22 + 0 · 21 + 1 · 20 = 8 + 4 + 0 + 1 = 13 .
Example
Convert 101102 to decimal.
Places: 24 , 23 , 22 , 21 , 20 . Keep 24 , 22 , 21 .
101102 = 1 · 16 + 0 · 8 + 1 · 4 + 1 · 2 + 0 · 1 = 16 + 0 + 4 + 2 + 0 = 22 .
4 Decimal → Binary (integers)
Algorithm
Algorithm (Repeated division by 2).
1. Divide the decimal integer by 2. Record the remainder (0 or 1).
2. Replace the number with the quotient and repeat until the quotient is 0.
3. The binary representation is the remainder sequence read in reverse (last re-
mainder is the leftmost bit).
2
Example
Convert 2210 to binary.
22 ÷ 2 = 11 remainder 0
11 ÷ 2 = 5 remainder 1
5÷2=2 remainder 1
2÷2=1 remainder 0
1÷2=0 remainder 1
Read remainders from bottom to top: 1 0 1 1 0 so 2210 = 101102 .
Example
Convert 1310 to binary.
13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Read up: 11012 . Thus 1310 = 11012 .
(Optional) Fractions
Binary fractions use negative powers of two:
0.1012 = 1 · 2−1 + 0 · 2−2 + 1 · 2−3 = 1
2
+0+ 1
8
= 0.625 .
Algorithm
Decimal fraction → Binary fraction (repeated doubling).
1. Multiply the fractional part by 2.
2. The integer part of the result (0 or 1) is the next binary digit after the point.
3. Drop the integer part and repeat with the new fractional part.
Stop after enough bits or when the fraction becomes 0.
Example
Convert 0.62510 to binary.
0.625 × 2 = 1.25 ⇒ write 1; keep 0.25.
0.25 × 2 = 0.5 ⇒ write 0; keep 0.5.
0.5 × 2 = 1.0 ⇒ write 1; done.
So 0.62510 = 0.1012 .
3
5 Common pitfalls
Common pitfalls
• Reading remainders in the wrong order: always reverse them when build-
ing the binary number.
• Mislabeling place values: the rightmost bit is 20 , not 21 .
• Dropping a 1-bit: when summing powers of two, include every position with
a 1.
• Fractions may not terminate: some decimals become repeating binary (just
like 1/3 in decimal).
6 Practice problems
Convert the following. Show your steps.
A. Binary → Decimal
A1. 100112
A2. 1110002
A3. 1010112
A4. 100000012
Solution.
A1. 100112 = 1 · 24 + 0 · 23 + 0 · 22 + 1 · 21 + 1 · 20 = 16 + 0 + 0 + 2 + 1 = 19 .
A2. 1110002 = 1 · 25 + 1 · 24 + 1 · 23 + 0 + 0 + 0 = 32 + 16 + 8 = 56 .
A3. 1010112 = 1 · 32 + 0 · 16 + 1 · 8 + 0 · 4 + 1 · 2 + 1 · 1 = 32 + 0 + 8 + 0 + 2 + 1 = 43 .
A4. 100000012 = 1 · 27 + 1 · 20 = 128 + 1 = 129 .
B. Decimal → Binary
B1. 2510
B2. 4010
B3. 7310
B4. 25510
Solution.
4
B1. 25: remainders up: 110012 . So 2510 = 110012 .
B2. 40: remainders up: 1010002 . So 4010 = 1010002 .
B3. 73: remainders up: 10010012 . So 7310 = 10010012 .
B4. 255: all ones up to 27 : 111111112 .
C. (Optional) Fractions
C1. 0.37510 →?2
C2. 0.1012 →?10
Solution.
C1. 0.375 × 2 = 0.75 ⇒ 0; 0.75 × 2 = 1.5 ⇒ 1; keep 0.5; 0.5 × 2 = 1.0 ⇒ 1. Thus
0.0112 .
C2. 0.1012 = 1 · 2−1 + 0 · 2−2 + 1 · 2−3 = 1
2
+ 1
8
= 0.625 .
7 Self-check strategies
• Round-trip test: convert binary → decimal, then back to binary; you should get
the original.
• Magnitude check: compare with the nearest power of two to see if your answer
is reasonable.
• Bit pattern sanity: a number just below 2k in decimal should look like 111 . . .2
(k ones).