Module-2c
Module-2c
FACULTY OF COMPUTING
2
3
Integer: Unsigned Number
no negative values.
00000000 2 −111111112
2 72 6 2 52 4 2 32 2 212 0 2 72 6 2 52 4 2 32 2 212 0
128 + 64 + 32 +16 + 8 + 4 + 2 +1
4
Integer: Unsigned Number
5
Integer: Unsigned Number
range of number
Example:
6
Integer: Unsigned Number
7
Integer: Unsigned Number
Example:
4096 4095
4095
8
Integer: Signed Number
positive negative
9
(+ve) à 0 (-ve) à 1
Example:
i. +4 0 ii. -12 1
Example:
Value in
decimal?
+17
-3
10
11
Sign and magnitude
*Note:
A negative
number has the
same magnitude
bits as the
corresponding
positive number
but the sign bit is 0 01110
01110
1 rather than a 0. 1 100100
100100
Positive Negative
13
Example:
-25 = - (+25)
= - (0 0 0 1 1 0 0 1) (8-bit binary system)
= 10011001
14
Complement Numbers
B’s complement
(B-1)’s complement
15
integers binary
16
1’s complement
*Note:
Positive number For (-ve)
represent the
same way as the
positive sign-
magnitude
numbers.
A negative
number is the 1’s
complement of
the corresponding - (0100100) = 1011011
positive number. assume 7-bits binary system
-7 1000
-7 = - (+7)
= - (0 1 1 1)
= 1000 1’s
Complement
18
Example:
-25 = - (+25)
= - (0 0 0 1 1 0 0 1) (8-bit binary system)
= 11100110 1’s Complement
19
2’s complement
*Note:
A negative
number is the 2’s
complement of
the corresponding
positive number. - (0100100) = 1011011
assume 7-bits binary system (1’s)
= 1011100 (2’s)
-7 1001
2’s Complement:
1’s Complement: 1000
-7 = - (+7) + 1
= - (0 1 1 1) -----------
= 1000 1001
21
Example:
-25 = - (+25)
= - (0 0 0 1 1 0 0 1)
= 11100110 1’s Complement
= 11100111 2’s Complement
22
Example:
-23 = - (+23)
= - ( 0 0 1 0 1 1 1)
= 1101000
(7-bit binary system)
Example:
2’s Complement:
1101000
+ 1
------------------
1101001
23
Ex
tr
a
Exercise 2c.1:
Exercise 2c.2:
24
Summarized of signed representation
25
Addition
26
27
Example:
Result wrong
28
Example:
-(+30) à - (0 0 0 1 1 1 1 0)
Carry bit is ignore !
1 1 1 0 0 0 0 1 (1’s)
1
1 1 1 0 0 0 1 0 (2’s)
29
Substraction
- (0 0 1 1 1 1)
à 1 1 0 0 0 0 (1’s)
1
1 1 0 0 0 1 (2’s)
30
Example:
-17 = - (+17)
= - (0 1 0 0 0 1) (6-bits)
= 1 0 1 1 1 0 (1’s)
1
1 0 1 1 1 1 (2’s)
31
Example:
101000
32