CMP 101 Set 5 Computer Arithmetic
CMP 101 Set 5 Computer Arithmetic
Computer Arithmetic
Every thing that can be done in decimal number system can also be done in binary number system
Binary Arithmetic
13-04-2012
Addition
0 0 1 1
Like in Decimal System
13-04-2012
+ + + +
0 1 0 1 9
= = = =
0 1 1 0 +
Examples 1 0 1 1 0 1 1 1
5 2
1 0 0 1 1 1 0 0 1
1
13-04-2012
1 0
Examples
1 1 1 1 1
1 0 0 1 1 1 1 1 0 1 1
1 0 0 0 0 1 0
13-04-2012
0 0 1 1
0 1 0 1
13-04-2012
Subtraction
1 2
2 0 1
0 1
13-04-2012
0
0
0 1
0
1
1
0 1
1
1 0
1
Complementary Subtraction
Complement = (basen -1) m
Where:
Complementary Method
Find complement of subtrahend
Add the minuend If there is carry of 1, add it.
If no carry, then re-complement the result and negate the number.
13-04-2012
Complementary Method
Subtract 5610 (subtrahend) from 9210 (minuend)
-17
Complementary Method
Subtract 0111000 from 10111000
0 1 + 1 1 0
1 0 0 1
1 0 1 0
1 0 1 0
0 1 1 0
13-04-2012
Complementary Method
Subtract 100011 from 010010
1 0 0 1 - 0
13-04-2012
0 1 1 0 1
0 1 0 1 0
0 1 0 1 0
1 0 1 1 0
1 0 0 0 1
Multiplications
0 0 1 1 0 1 0 1 0 0 0 1 Multiplier Multiplicand
0 0 0 1 0 1 1 0 1
1 1 1 0 0 0 1
0 0 0 0 0
1 0 0 1 1 0 0
1 0 1 0 1 0 0 1
1 0 1 0 1 0 1 0 S S
1 0 1 1 0 1 0
0 1 0
13-04-2012
Multiplications
1 x 1 1 1 1
1
Carry
1
1
1 1 0
1
1 1 1 1 1 0
1
1 1 1 1
0
1
1 1 1
13-04-2012
Division
Quotient 0 1 0 1
Divisor 1 1 0
1 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 0
Dividend
Result
0101.11
1 1
1 1 0 1
Remainder
13-04-2012
13-04-2012