0% found this document useful (0 votes)
4 views

Module-2c

The document discusses the representation of integers in binary, focusing on unsigned and signed numbers, including sign-magnitude, 1's complement, and 2's complement forms. It provides examples of converting decimal numbers to binary and vice versa, along with the rules for addition and subtraction of signed binary numbers. Additionally, it highlights the importance of the sign bit and the range of values that can be represented in different bit systems.

Uploaded by

minnieung2017
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)
4 views

Module-2c

The document discusses the representation of integers in binary, focusing on unsigned and signed numbers, including sign-magnitude, 1's complement, and 2's complement forms. It provides examples of converting decimal numbers to binary and vice versa, along with the rules for addition and subtraction of signed binary numbers. Additionally, it highlights the importance of the sign bit and the range of values that can be represented in different bit systems.

Uploaded by

minnieung2017
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/ 32

1

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

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


0 0
1 1

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

*Resource: Floyd, Digital Fundamentals, 10th Edition, 2009 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:
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)

*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
Ex
tr
a

Exercise 2c.1:

Determine the decimal value of this signed binary number


(10010101) expressed in sign-magnitude.

Exercise 2c.2:

Express the decimal number -39 as an 8-bit number in the


sign-magnitude, 1’s complement, and 2’s complement forms.

24
Summarized of signed representation

25
Addition

26
27
Example:

(+127) 0 111 1111


(+74) + 0 100 1010
1 100 1001

Result wrong

28
Example:

(+60) 0011 1100


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

-(+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

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

32

You might also like