Binary to Decimal to Binary Conversion
Decimal System = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} 10 - digits
Binary System = {0, 1}2 - digits
Octal System = {0, 1, 2, 3, 4, 5, 6, 7}8 - digits
Hexadecimal System = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F} 16 digits
OBSERVE (have students read the number 8253 and record what they say)
8253 = 8000 + 200 + 50 + 3
= 8x1000 + 2x100 + 5x10 + 3x1
place value
= 8x103 + 2x102 + 5x101 + 3x100
base
This is called the expanded notation for the integer 8253.
The place values in the decimal system are the powers of 10, namely, (3, 2, 1, 0)
By analogy one can expand any binary number like 110101 in the same way.
OBSERVE (the binary number 110101 can be expanded the same way)
1101012 = 1x25 + 1x24 + 0x23 + 1x22 + 0x21 + 1x20
= 1x32 + 1x16 + 0x8 + 1x4 + 0x2 + 1x1
= 32 + 16 + 0 + 4 + 0 + 1
= 5310
The place values in the binary system are the powers of 2, namely, (5, 4, 3, 2, 1, 0)
Page 1 of 18
Convert a binary number into a decimal number
Multiply each binary digit by its base 2 raised to its place value and then add all the products. It
is that simple.
Convert a decimal to binary
Divide successively the decimal number by 2 as shown below.
53/2
26/2
13/2
6/2
3/2
1/2
= 26 remainder 1
= 13 remainder 0
= 6 remainder 1
= 3 remainder 0
= 1 remainder 1
= 0 remainder 1
(MSB) 1 1 0 1 0 1 (LSB)
MSB (most significant bit)
LSD (least significant bit)
8 bits = 1 byte
128 64 32 16
1
Page 2 of 18
Assignment # 1
Decimal to Binary Conversion
a. Convert the following decimal numbers to their binary equivalents.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
1510
1810
4210
10010
23510
110
29410
11710
8610
409010
409510
150210
37710
50110
82810
90710
400010
345610
227810
196710
Page 3 of 18
Binary to Decimal Conversion
b. Convert the following binary numbers to their decimal equivalents.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
1102
1012
11101102
10111102
01101102
111112
10102
1101112
110110111012
1110001110012
1110101101002
1111111101112
1010110101012
1111112
0001010012
1111111111112
Page 4 of 18
Binary Addition
Rules
1.
2.
3.
4.
5.
0
0
1
1
1
1
1
1
1
1
1
0
0
+
+
+
+
+
0
1
0
1
1
=
=
=
=
=
0
1
1
0
1
with a carry of
with a carry of
1
1
Example
+
1
carries
1
1
0
sum
Page 5 of 18
Assignment # 2
Perform the following binary additions.
1. 10110
+ 101
2. 100
+10
3. 11011
+0010
8. 1111
101
+1000
9.
4. 10110111
+
1
110111
100100
+110001
5. 1101
101
+11
10.
100111
111001
+101101
6.
101
1
+110
11.
11011001
10010011
+11100011
7. 1110
100
+11
12.
11011011
10111011
00101011
01010111
+01111101
Page 6 of 18
Binary Multiplication
The partial product is moved one position to the left as each successive
multiplier is used. Then you add the products two at a time.
Example
+
1
1
0
0
1
1
1
0
1
0
1
1
0
0
0
1
1
0
1
0
1
x
1
0
0
1
1
0
1
0
1
0
0
0
1
0
1
1
0
1
1
1
0
0
1
0
Sum of partial products 2 at a time: These are difficult binary additions.
+
+
1
1
0
+
1
0
1
1
1
1
0
0
0
1
0
1
1
1
0
1
0
0
1
1
1
0
1
1
0
1
0
0
0
0
1
1
0
1
0
0
0
0
0
1
1
0
0
0
1
0
1
Page 7 of 18
Assignment # 3
Multiply the following binary numbers.
1.
11011
X110
2.
1011101
X101
3.
101011101011
X10000
Page 8 of 18
Binary Subtraction
Rules
1.
2.
3.
4.
0
1
1
0
0
0
1
1
=
=
=
=
0
1
0
1
with a borrow of 1 from the previous column
Example
1
1
1
1
0
0
1
0
0
0
1
1
1
1
0
What happens when we need to borrow from a digit which is 0.
Again we borrow from the first nonzero digit to the left, however now each
0 1 1
1 1 10 10 10
1 0 0 1 1
0 0 1 0 1
intervening 0 becomes 10 from which we borrow 1 and leave 1.
That is 0 becomes 1, namely, (10 -1 = 1)
Example
Page 9 of 18
Assignment # 4
Subtract the following binary numbers.
1.
101000001
- 010111101
2.
1010111010
- 0101110101
3.
101011010111
- 011111111101
4.
101111100111
- 010101110010
Page 10 of 18
Division
Observe
11112 = 1510
810 = 10002 > 1112 = 710
410 = 1002 > 112 = 310
210 = 102 > 12 = 110
Page 11 of 18
Binary Division
346
123 42558
-369
565
-492
738
-738
0
First subtract 3x102 times the
divisor from the dividend, then
4x101 times the divisor from the
dividend, then 6x100 times the
divisor from what is left. The
dividend originally contained the
divisor 3x102+4x101+6x100=346
times.
Binary division likewise reduces to repeated subtraction of the divisor times
a power of 2. {(1x24+1x23+0x22+1x21+1x20)=11011}
Example:
11011
It can fit either once or zero.
11 1010001
-11
100
-11
10
Page 12 of 18
-00
100
-11
11
-11
0
A remainder is possible
Assignment # 5
Divide the following binary numbers
1.
10 100
2.
100 10000
3.
10100 1100100
Page 13 of 18
Review
Find the binary sums
1. 1101
+111
2. 110011
+11101
3. 111001111
+11000011
Find the binary sum
1.
11001
11100
Page 14 of 18
1011
+110011
Find the binary products
1.
11100111
X11
2.
111011
X1011
Find the binary differences
1.
1100011
-110111
2.
10101010
-110011
Find the binary quotient
Page 15 of 18
1.
111 1011011
Conversion Tables
(You need to remember them)
Decimal
0
1
2
3
4
5
6
7
8
9
0
0
0
0
0
0
0
0
1
1
Binary
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
0 0 0
0 0 1
Page 16 of 18
Hexadecimal
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
Binary
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Page 17 of 18
To convert a Decimal to Octal or Hexadecimal convert it first to Binary and
then group the bits in 3 for an Octal or group the bits in 4 for a Hexadecimal
Page 18 of 18