Course 2
Course 2
Dr MESSAOUDI M.A.
Chapter_Three:
Arithmetic of signed
numbers
4 0 to 24-1 (15)
8 0 to 28-1 (255)
16 0 to 216-1 (65,535)
32 0 to 232-1 (4,294,967,295)
3
Unsigned Binary Numbers
Decimal Unsigned Decimal Unsigned
binary binary
+0 0000 +8 1000
+1 0001 +9 1001
Unsigned Number +2 0010 +10 1010
Representation in 4 Bits +3 0011 +11 1011
+4 0100 +12 1100
+5 0101 +13 1101
+6 0110 +14 1110
+7 0111 +15 1111
4
Signed Integer Representation
5
Signed Integer Representation
Positive
Sign and 1’s Complement 2’s Complement
+N Integers -N
Magnitude N N*
(all systems)
+0 0000 -0 1000 1111 -------
+1 0001 -1 1001 1110 1111
+2 0010 -2 1010 1101 1110
+3 0011 -3 1011 1100 1101
+4 0100 -4 1100 1011 1100
+5 0101 -5 1101 1010 1011
+6 0110 -6 1110 1001 1010
+7 0111 -7 1111 1000 1001
-8 ------- ------- 1000
(a) Sign-magnitude Representation
bn-1 bn-2 b1 b0
Sign
Magnitude
8
(a) Sign-magnitude Representation
Sign-magnitude Addition
(a) Sign-magnitude Representation
Sign-magnitude Addition
(a) Sign-magnitude Representation
Sign-magnitude Addition
(a) Sign-magnitude Representation
Sign-magnitude Subtraction
(a) Sign-magnitude Representation
Sign-magnitude Subtraction
(b) 1’s Complement Representation
• Basic idea:
• Positive numbers are represented exactly as in sign-magnitude form.
• Negative numbers are represented in 1’s complement form.
• How to compute the 1’s complement of a number?
• Complement every bit of the number (1 to 0, and 0 to 1).
• Most Significant Bit (MSB) will indicate the sign of the number (0:
positive, 1: negative).
14
(b) 1’s Complement Representation
• Basic idea:
• Positive numbers are represented exactly as in sign-magnitude form.
• Negative numbers are represented in 2’s complement form.
• How to compute the 2’s complement of a number?
• Complement every bit of the number (1 to 0 and 0 to 1), and then add
one to the resulting number.
• MSB will indicate the sign of the number (0: positive, 1: negative).
19
(c) 2’s Complement Representation
21
(c) 2’s Complement Representation
22
(c) 2’s Complement Representation
23
(c) 2’s Complement Representation
24
Overflow and Underflow
11 ≠ -5 OVERFLOW
Example : underflow
-12 ≠ 4 UNDERFLOW