CSC201_Week3-Module2
CSC201_Week3-Module2
Week 3 – Module 2
DR(MRS) O.E.OJO
1
• Character Representation
- Binary Addition
- One’s complement
- Two’s Complement
2
3
4
Computer Arithmetic
510 X 210
510 - 1 0 12
X 210 - 0 1 02
• 0 0 0
• 1 0 1
0 0 0
• 1010= 0 1 0 1 02 6
7
One’s Complement
• The one’s complement of a binary number is
defined as the value obtained by inverting all
the bits in the binary representation of the
number (swapping 0s for 1s and vice versa).
11
Find the two Complement of +3
• +3= 0 0 1 1
• One’s comp. 1 1 0 0
• Add 1 + 1
two’s Comp. = 1 1 0 1
12
Classwork: Subtract 18 from 25 using two’s
complement
• 2510 - 1810 = 710
• Steps involved:
• (i) convert 18 to binary
• (ii) find the one’s complement of the binary
equivalent
• (iii) Add 1 to the one’s complement to change it
to two’s complement
• (iv) Add the result to 25 in binary
13
(i) Convert 18 to binary
2 18
2 9 r 0
2 4 r 1
2 2 r 0
2 1 r 0
0 r 1
18 = 100102
14
(ii) & (iii) Find the one’s complement of
18 = 100102 and Add 1
• Decimal 18
• Binary Equi.1 0 0 1 0
• One’s Compl. 0 1 1 0 1
• Add 1 + 1
• Two’s Compl. 0 1 1 1 0
15
(iv) Add the result to 25 in binary
25 = 0 1 1 0 0 1
• + 0 0 1 1 1 0
Parity Bit 1 0 0 1 1 1
•b 16
CHARACTER CODES