9/27/12
1
FACULTY OF COMPUTER SCIENCE & INFORMATION SYSTEM
2
Integer: Unsigned Number
no negative values.
3 4
Example:
5 6
2012/2013-sem1 @ m 1
9/27/12
Example:
4096 4095
4095
7 8
Integer: Signed Number (+ve) à 0 (-ve) à 1
Example:
positive negative
0 1
Example:
0 (+ve) or 1 (-ve) positioned at MSB
9 10
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
11 *Resource: Floyd, Digital Fundamentals, 10th Edition, 2009 12
2012/2013-sem1 @ m 2
9/27/12
Lower bound < decimal < Upper bound
-(24-1-1) < decimal < +(24-1-1)
-(23-1) < decimal < +(23-1)
-(8-1) < decimal < +(8-1)
-7 < decimal < +7
Example: Integer 4 bits Example:
Positive Negative Express the decimal number +25 and -25 as an 8-bit signed
binary number in the sign-magnitude forms.
Solution: +25 = 11001
=00011001 (8-bit binary system)
(Sign bit) (Magnitude bits)
-25 = - (+25)
= - (0 0 0 1 1 0 0 1) (8-bit binary system)
= 10011001
13 14
integers binary
15 16
1’s complement
Example: Integer 4 bits
*Note:
Positive number For (-ve)
represent the
same way as the
positive sign-
magnitude
numbers.
A negative -7 1000
number is the 1’s
complement of the
corresponding - (0100100) = 1011011 -7 = - (+7)
positive number. = - (0 1 1 1)
= 1000 1’s Complement
*Resource: Floyd, Digital Fundamentals, 10th Edition, 2009 17 18
2012/2013-sem1 @ m 3
9/27/12
2’s complement
Example:
Express the decimal number +25 and -25 as an 8-bit signed
binary number in the 1’s complement forms.
Solution: +25 = 11001
= (0 0 0 1 1 0 0 1) (8-bit binary system)
*Note:
(Sign bit) (Magnitude bits) A negative
number is the 2’s
complement of the
corresponding
-25 = - (+25) positive number. - (0100100) = 1011011 (1’s)
= - (0 0 0 1 1 0 0 1) (8-bit binary system)
= 1011100 (2’s)
= 11100110 1’s Complement
19 *Resource: Floyd, Digital Fundamentals, 10th Edition, 2009 20
Example:
Express the decimal number +25 and -25 as an 8-bit signed
binary number in the 2’s complement forms.
Solution: +25 = 11001
=00011001 (8-bit binary system)
-7 1001
(Sign bit) (Magnitude bits)
2’s Complement:
1’s Complement: 1000 -25 = - (+25)
-7 = - (+7) + 1 = - (0 0 0 1 1 0 0 1)
= - (0 1 1 1) ----------- = 11100110 1’s Complement
= 1000 1001 = 11100111 2’s Complement
21 22
Ex
tr
a
Example:
Exercise 4:
Determine the decimal value of this signed binary number
-23 = - (+23)
(10010101) expressed in sign-magnitude.
= - ( 0 0 1 0 1 1 1)
= 1101000
(7-bit binary system)
Example:
Exercise 5:
2’s Complement:
1101000 Express the decimal number -39 as an 8-bit number in the
+ 1 sign-magnitude, 1’s complement, and 2’s complement forms.
------------------
1101001
23 24
2012/2013-sem1 @ m 4
9/27/12
Summarized of signed representation Addition
25 26
Example:
27 28
Substraction
Example:
29 30
2012/2013-sem1 @ m 5
9/27/12
Example:
Example:
101000
31 32
2012/2013-sem1 @ m 6