0% found this document useful (0 votes)
10 views33 pages

Module 2c Aritmetic Operations

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views33 pages

Module 2c Aritmetic Operations

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

1

FACULTY OF COMPUTING
2
3
Integer: Unsigned Number

no negative values.

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

0 (+ve) or 1 (-ve) positioned at MSB


0 0
1 1

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

*Resource: Floyd, Digital Fundamentals, 10th Edition, 2009 11


(+ve)  0 (-ve)  1

Example:

i. +4 0 ii. -12 1

Example:
Value in
decimal?
+17
-3

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

Positive Negative

13
Example:

Express the decimal number +25 and -25 as an 8-bit signed


binary number in the sign-magnitude forms.

Solution: +25 = in binary?


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

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

*Resource: Floyd, Digital Fundamentals, 10th Edition, 2009 17


Example: Integer 4 bits

-7 1000

-7 = - (+7)
= - (0 1 1 1)
= 1000 1’s
Complement
18
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)

(Sign bit) (Magnitude bits)

-25 = - (+25)
= - (0 0 0 1 1 0 0 1) (8-bit binary system)
= 11100110 1’s Complement

19
2’s complement

*Note:
Positive number
represent the
same way as the
positive sign-
magnitude
numbers.

A negative
number is the 2’s
complement of
the corresponding
positive number.
- (0100100) = 1011011 (1’s)
assume 7-bits binary system

= 1011100 (2’s)

*Resource: Floyd, Digital Fundamentals, 10th Edition, 2009 20


Example: Integer 4 bits

-7 1001

2’s Complement:
1’s Complement: 1000
-7 = - (+7) + 1
= - (0 1 1 1) -----------
= 1000 1001
21
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)

(Sign bit) (Magnitude bits)

-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
Addition

25
26
Example:

(+127) 0 111 1111


(+74) + 0 100 1010
1 100 1001

Wrong result

27
Example:

(+60) 0011 1100


(-30) + 1110 0010
(+30) 10001 1110

-(+30)  - (0 0 0 1 1 1 1 0)
Carry bit is ignored !
1 1 1 0 0 0 0 1 (1’s)
+ 1
1 1 1 0 0 0 1 0 (2’s)

28
Substraction

- (0 0 1 1 1 1)
 1 1 0 0 0 0 (1’s)
1
1 1 0 0 0 1 (2’s)

29
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)

30
Example:

101000
-9 = - (+9) -15 = - (+15)
= - (0 0 1 0 0 1) (6-bits) = - (0 0 1 1 1 1) (6-bits)
= 1 1 0 1 1 0 (1’s) = 1 1 0 0 0 0 (1’s)
1 1
1 1 0 1 1 1 (2’s) + 1 1 0 0 0 1 (2’s)

31
END OF MODULE 2

32
33
34

You might also like