Computer Arithmetic: CP1-Lecture 3
Computer Arithmetic: CP1-Lecture 3
Arithmetic
CP1-Lecture 3
Binary Addition
Binary Addition
10101 = 21
• Two n-bit values
– Add individual bits + 11001 = + 25
– Propagate carries 101110 46
Binary Subtraction
Binary Subtraction
• 1’s Complement
• 2’s Complement
Binary Subtraction
• 1s Complement Subtraction
- Subtraction of binary numbers using the 1’s complement
method allows subtraction only by addition.
1001001011
1’s complement = 0110110100
Binary Subtraction: 1’s
complement
Answer: 10000 2
Example
101011 2 101011 2
- 111001 2 + 000110 2
110001 001110 2
Negative Value
Answer:-001110 2
Binary Subtraction: 1’s
complement
DROP
Answer: 100000 2
Example
10110 2
- 11010 2 00101
+ 1 10110 2
00110 + 00110 2
11100 2
00011
+ 1
Answer: -00100 2 00100 2
Binary Multiplication
Binary Multiplication
A B AB
0 0 0
0 1 0
1 0 0
1 1 1
Example
1110
x 1011
1110
1110
0000
1110
10011010
Octal Addition
Example
11
6437
+ 2510
99
- 88
11147
Octal Subtraction
Example
8
00 8
11 147
8 9
- 6 437
2 510
Hexadecimal Addition
Example
11
7 C 3 9
+ 3 7 F 2
20 18 11
- 16 16
B 4 2 B
Hexadecimal
Subtraction
Example
B 16
7 C 3 9
19
- 3 7 F 2
4 4 4 7
“For the Lord gives wisdom; From His mouth come
knowledge and understanding.”
–Proverbs 2:6