Lecture 3 Binary Arithmetic
Lecture 3 Binary Arithmetic
Lecture Outline
• Binary Arithmetic
Addition and subtraction
Multiplication and Division
• Representation of Negative Numbers
1’s compliment, 2’s complement, and sign & magnitude
Number Systems & Conversions
Binary Arithmetic
• Binary Addition
0+0=0
0+1=1+0=1
1 + 1 = 0 and carry 1
• Binary Subtraction
0-0=0
0 - 1 = 1 and borrow 1
1-0=1
1-1=0
• Binary Multiplication
0X0=0
0X1=1X0=0
1X1=1
• An Example 1101
X1011
= 1310 1101
+1101
= 1110
100111 1st Partial sum
1101 +0000
1101 100111 2nd Partial sum
0000 +1101
1101 Final prod
10001111 = 14310
Number Systems & Conversions
Binary Arithmetic
1 101 = 1110
1011 10010001 = 14510
1011
01110
1011
001101
1011
1 0 ← Remainder = 210
Representation of Negative Numbers
• Unsigned Number
bn −1 bn − 2 … b1 b0
Magnitude
MSB LSB
• Signed Number
bn −1 bn − 2 … b1 b0
Magnitude
Sign MSB LSB
• Three Representations
Sign & Mag, 1’s Complement, and 2’s Complement
Positive Integers Negative Integers
+N All three the -N Sign & 1’s 2’s
Same Magnitude Complement Complement
+0 0000 -0 1000 1111
+1 0001 -1 1001
+2 0010 -2 1010 1101
+3 0011 -3 1011 1100
+4 0100 -4 1100 1100
+5 0101 -5 1010 1011
+6 0110 -6 1110 1001
+7 0111 -7 1111 1000 1001
-8
Representation of Negative Numbers
− ( 2n−1 ) =
− ( 23 ) =
−8 + ( 2n−1 − 1) =+ ( 23 − 1) =+7
Representation of Negative Numbers