Module 2c Arithmetic Operations (Student)
Module 2c Arithmetic Operations (Student)
1
FACULTY OF COMPUTER SCIENCE & INFORMATION SYSTEM
2
no negative values.
3 4
Example:
5 6
2012/2013-sem1 @ m 1
9/27/12
Example:
4096 4095
4095
7 8
Example:
positive negative
0 1
Example:
0 (+ve) or 1 (-ve) positioned at MSB
9 10
*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
2012/2013-sem1 @ m 2
9/27/12
Positive Negative Express the decimal number +25 and -25 as an 8-bit signed
binary number in the sign-magnitude forms.
-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
2012/2013-sem1 @ m 3
9/27/12
2’s complement
Example:
*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
Example:
-7 1001
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:
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
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