1 chapter 3 number representation. 2 objective...

115
1 Chapter 3 Number Representation

Post on 22-Dec-2015

253 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

1

Chapter 3 Number Representation

Page 2: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

2

Objective

在這一章中,我們將學習在電腦中使用的數字系統:在電腦中如何用一串的 0 與 1 來表示一個數字,如何將一個數字儲存起來。

我們將會學到表示整數與表示小數的各種方式。特別要注意的是,由於在電腦中是以固定長度的0/1 字串來表示數字,一定會有可表示的數字的範圍。而且會有些數字會無法精確的表示出來,只能儘量提高其精確度。

Page 3: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

3

Outlines

Decimal and Binary Conversion Integer Representation Excess System Floating-Point Representation Hexadecimal Notation Key Terms Summary Homework

Page 4: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

4

Section 3.1Decimal and Binary

Section 2.1, 2.2 in Version 2

Section 2.3 in Version 2 is ignored.

Page 5: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

5

Numbering System

Four numbering systems are dominant today in the world of computers:• Decimal system• Binary system• Hexadecimal system (new)• Octal system (new)

They are positional number systems.• Roman numerals are an example of non-positional

number systems.

Page 6: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

6

Decimal System

The position of number is meaningful. Base (or radix) of the decimal system = 10

10 decimal digits: 0-9

Page 7: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

7

Decimal Real Number

The following shows the place values for the real number +24.13.

Integral part Fractional part

Page 8: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

8

Binary System

Base of the decimal system = 2 Digits are 0 and 1.

= 24310

Page 9: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

9

Binary Real Number

• The following shows that the number (101.11)2 in binary is equal to the number 5.75 in decimal.

Integral part Fractional part

Page 10: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

10

Hexadecimal System

Base of the decimal system = 16 Digitals are 0, 1, …, 9, A, B, …, F.

The equivalent decimal number is N = 512 + 160 + 14 = 686.

Page 11: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

11

Octal System

Base of the decimal system = 8 Digitals are 0, 1, …, 8.

The equivalent decimal number is N = 512 + 128 + 40 + 6 = 686.

Page 12: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

12

Section 3.2Conversion

Base 10 Base 2

0 0

1 1

2 10

3 11

4 100

5 101

6 110

7 111

8 1000

9 1001

10 1010

Section 2.2 in Version 2

Page 13: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

13

Binary to Decimal Conversion

Multiple each binary digit by its corresponding weight (i.e., power of 2)

Page 14: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

14

Example 1

Question: Convert the binary number 110.11 to decimal.

Solution:

Page 15: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

15

Questions 1

1. Convert the binary number 11111111 to decimal.

2. Convert the binary number 10001000 to decimal.

3. Convert the binary number 111111.11 to decimal.

4. Convert the binary number 101.001 to decimal.

Page 16: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

16

Properties of Binary Number

1 1 10 2

11 3 100 4

111 7 1000 8

1111 15 10000 16

The value is multiplied by 2 if we add a 0 on the right side of binary number.

The value is divided by 2 if we remove a bit on the left side of the binary number.

20 + 21 +…+ 2n-1 = 2n - 1

1 1 10 2

11 3 110 6

111 7 1110 14

1111 15 11110 30

Page 17: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

17

Shift the Radix Point

To move the radix point left one digit• The new number = the original number 2• Left movement of x positions: multiple 2-x

To move the radix point right one digit • The new number = the original number 2• Right movement of x positions: multiple 2x

Original Number Move New Number

5.7510 = 101.112 1 10.1112 = 2.87510 = 5.75102

5.7510 = 101.112 1 1011.12 = 11.510 = 5.75102

Page 18: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

18

Decimal to Binary Conversion

32<45<64 45=32+13

8<13<16 45=32+8+5

4<5<8 45=32+8+4+1 20 + 21 +…+ 2n-1 = 2n - 1

Page 19: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

19

Idea of Conversion

1011012= 4510

How to get the position value a at 20?• Divide by 2, if the remainder is 1, a=1;

if the remainder is 0, a=0.• Dividing 45 by 2 equals to shift right the number

and get quotient 101102= 2210

We treat the quotient 2210 as a new number and repeat the same method to get the position value a at 21

Page 20: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

20

Decimal to Binary Conversion (1/2)

Divide the number continuously by 2 and write the quotient and the remainder.

202125 24 23 22

Page 21: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

21

Decimal to Binary Conversion (2/2)

45= 22 2 + 1

= (11 2 + 0) 2 + 1

= ((5 2 + 1) 2+ 0) 2 + 1

= (((2 2 + 1) 2 + 1) 2+ 0) 2 + 1

= ((((1 2 + 0) 2 + 1) 2 + 1) 2+ 0) 2 + 1

=(((((0 2 + 1) 2 + 0) 2 + 1) 2 + 1) 2+ 0) 2 + 1

= ((((1 2 + 0) 2 + 1) 2 + 1) 2+ 0) 2 + 1

= 1 25 + 0 24 + 1 23 + 1 22 + 0 21 + 1 20

4510 = 1011012

RemaindersQuotient

Page 22: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

22

Example 2

Question: Convert the decimal number 35 to binary.

Solution:

35=125 + 024 + 023 + 022 + 121 + 120

Quotient 0 ←1 ← 2 ← 4 ← 8 ←17←35

↓ ↓ ↓ ↓ ↓ ↓

Remainder 1 0 0 0 1 1

3510 = 1000112

Page 23: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

23

Changing Fractions to Decimal

We use a radix point in the same role as the decimal point.

Decoding the binary 101.101

Page 24: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

24

Changing Fractions to Binary

Repetitive multiplication: multiply the fraction by 2 (i.e., the radix point shift to right)• Carry: set to 1• No carry: set to 0

1/2

Page 25: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

25

Example 3

Question: Transform the fraction 0.875 to binary.

Solution: • Answer: 0.111

0.8752 0.752 0.52

0.875 1.750 1.5 1.0 0.0

0 . 1 1 1

Page 26: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

26

Example 4

Question: Transform the fraction 0.4 to a binary of 6 bits.

Solution: • No exact binary representation• Truncation error• Answer: 0.011001

0.42 0.82 0.62 0.22 0.42 0.82

0.4 0.8 1.6 1.2 0.4 0.8 1.6

0 . 0 1 1 0 0 1

Page 27: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

27

Question 2

1. Convert the decimal number 42 to binary.

2. Convert the decimal number 115 to binary.

3. Convert the decimal number 42 to octal number.

4. Convert the decimal number 115 to hexadecimal number.

5. Convert the binary number 1110111101010 to hexadecimal.

Page 28: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

28

Section 3.3Integer Representation

Section 3.2 in Version 2

Page 29: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

29

Range of Integers

Whole numbers are integers. No computer can store all the integers. The range of integers stored in computer depends

on the storage size. To use computer memory more efficiently, several

integer representation have been developed.

Negative numbers (0) Positive numbers (0)

Page 30: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

30

Taxonomy of Integers

Unsigned

Excess System

Integer Representation

One’sComplement

Two’sComplement

Signed

Sign-and-Magnitude

Page 31: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

31

Unsigned Integers Format

An unsigned integer is an integer without a sign.

To store an unsigned integer in N bits:1. The number is changed to binary.

2. If the number of bits is less than N, 0s are added to the left of the binary number so that there is total of N bits.

Page 32: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

32

Unsigned Integers N=3

N=3

0 〜 2N-1=23-1=7 Range: 0 〜 7

Base 10 Storage

0 000

1 001

2 010

3 011

4 100

5 101

6 110

7 111

Page 33: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

33

Unsigned Integers N=4

N=4

Range:

0 〜 2N-1=24-1=15

Range: 0 〜 15

Base 10 Storage

0 0000

1 0001

2 0010

3 0011

4 0100

5 0101

6 0110

7 0111

Base 10 Storage

8 1000

9 1001

10 1010

11 1011

12 1100

13 1101

14 1110

15 1111

Page 34: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

34

Range of Unsigned Integers

The range depends on the number N of bits the computer allocates to store an unsigned integer (to store its binary number).

Range: 0 〜 2N-1

Number of Bits Range Maximum unsigned integer

4 0 〜 15 15 = 24-1

8 0 〜 255 255 = 28-1

16 0 〜 65,535 65,535 = 216 -1

Page 35: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

35

Overflow

• The term overflow describes a condition in which a number is not within the range defined by the allocation.

Decimal 8-bit Allocation 16-bit Allocation

7 00000111 00000000 00000111

234 11101010 00000000 11101010

258 overflow 00000001 00000010

24,760 overflow 01100000 10111000

1,245,678 overflow overflow

Page 36: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

36

Example 5

Question: Store 7 in an 8-bit memory location. Solution:

1. 710 1112

2. Add five 0s to left• Result: 00000111

0 0 111000

Page 37: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

37

Example 6

Question: Store 258 in a 16-bit memory location.

Solution: 1. 25810 1 000000102

2. Add seven 0s to left• Result: 00000001 00000010

If you store 258 in an 8-bit memory location, overflow occurs.

Page 38: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

38

Questions 3

1. Store 65 in a 8-bit memory location.

2. Store 1025 in a 16-bit memory location.

Page 39: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

39

Interpretation of Unsigned Integers

How do you interpret an unsigned representation in decimal?

Use binary to decimal conversion method and get the result.

Page 40: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

40

Example 7

Question: Interpret 00101011 in decimal if the number was stored as an unsigned integer.

Solution:

Binary 0 0 1 0 1 0 1 1Weights 128 64 32 16 8 4 2 1

------------------------------------------------------------- 32 + 0 + 8 + 0 + 2 + 1 Decimal =43

Page 41: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

41

Applications of Unsigned Integers Format

Unsigned integers representation can improve the efficiency of storage because you need not to store the sign of the integer.

Cases of applications:• Counting• Addressing• Storing other data type: text, images, audio, video

Page 42: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

42

Signed Integer

1. Sign-and-magnitude

2. One’s complement

3. Two’s complement

4. Excess system (See Section 3.4)

When we use a 4-bit allocation to store signed integers, the available range is divided into two parts: positive and negative integers.

How to design your own representation?

Page 43: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

43

Sign-and-Magnitude Format (1/2)

In sign-and-magnitude representation, the leftmost bit defines the sign of the number.• If it is 0, the number is positive.• If it is 1, the number is negative.

The rest N-1 bits define the magnitude of the number.• Magnitude: the absolute value of the number• To store the binary representation of its absolute

value.

Page 44: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

44

Sign-and-Magnitude Format (2/2)

0 0 0 0 1 0 0 0

sign magnitude

Decimal: +8 Sign-and-magnitude: 00001000 (or 08H)

1 0 0 0 1 0 0 0

Decimal: -8 Sign-and-magnitude: 10001000 (or 88H)

Page 45: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

45

Sign-and-Magnitude N=3

N=3

2N-1-1=22-1=3

Range: -3 〜 3

Base 10 storage

0 000

1 001

2 010

3 011

-0 100

-1 101

-2 110

-3 111

Page 46: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

46

Sign-and-Magnitude N=4

N=4

2N-1-1=23-1=7

Range: -7 〜7

Base 10 Storage

0 0000

1 0001

2 0010

3 0011

4 0100

5 0101

6 0110

7 0111

Base 10 Storage

-0 1000

-1 1001

-2 1010

-3 1011

-4 1100

-5 1101

-6 1110

-7 1111

Page 47: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

47

Representation of Sign-and-Magnitude Integers

To store a signed integer in N bits:1. The number is changed to binary. The sign is ignored.

2. If the number of bits is less than N-1, 0s are added to the left of the binary number so that there is total of N-1 bits.

3. If the number is positive, 0 is added to the leftmost significant bit.

4. If the number is negative, 1 is added to the leftmost significant bit.

Page 48: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

48

Range of Sign-and-Magnitude Format

Range of N-bit memory location:

Range: - (2N-1-1) 〜 + (2N-1-1)

Number of Bits Range

4 -7 〜 7 (1111 〜 0111)

8 -127 〜 127 (1111 1111 〜 0111 1111)

16 -32,767 〜 32,767

32 -2,147,483,647 〜 2,147,483,647

N-1 bits1

Page 49: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

49

Positive and Negative 0

There are two 0s in sign-and-magnitude representation: positive 0 and negative 0.

In an 8-bit allocation:+ 0 → 00000000

- 0 → 10000000

Page 50: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

50

Example 8

Question: Store +28 and -28 in an 8-bit memory location using sign-and-magnitude representation.

Solution:1. +2810 2810 111002

2. Add two 0s to make 7 bits: 0011100

3. Add the sign bit: Result= 0001110

1. - 2810 2810 111002

2. Add two 0s to make 7 bits: 0011100

3. Add the sign bit: Result= 1001110

Page 51: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

51

Example 9

Question: Store -258 in an 16-bit memory location using sign-and-magnitude representation.

Solution: 1. -25810 25810 1 000000102

2. Add six 0s to make 15 bits: 0000001 000000102

3. Add the sign bit: Result= 10000001 000000102

Page 52: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

52

Interpretation of Sign-and-Magnitude Integers in Decimal

How do you interpret an sign-and-magnitude representation in decimal?1. Ignore the leftmost bit.

2. Change the N-1 bits from binary to decimal.

3. Attach a + sign to the number if the leftmost bit =0.

4. Attach a – sign to the number if the leftmost bit =1.

Page 53: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

53

Example 10

Question: Interpret 10111011 in decimal if the number was stored as a sign-and-magnitude integer.

Solution: 1. Ignore the left most bit 101110112 01110112

2. Change to decimal 01110112 5910

3. Add – sign since the leftmost bit =1

Result= - 59

Page 54: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

54

Applications of Sign-and-Magnitude Format

It is not really used to store signed numbers. Disadvantage:

• Operations are not easy.• There are two 0’s.

Advantage:• Transfer from decimal to binary, and vice versa, is very

easy.

Cases of applications:• When we quantize an analog signal, such as audio, the

sign-and-magnitiude representation is used.

Page 55: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

55

Questions 4

1. Store -64 in an 8-bit memory location using sign-and-magnitude representation.

2. Interpret 10100001 in decimal if the number was stored as a sign-and-magnitude integer.

Page 56: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

56

One’s Complement Format (1/2)

To store an positive integer K in N bits:• Change K to binary format.• 0’s are added to the left to the number to make a

total of N bits.

0 0 0 1 0 0 0One’s complement: 08H

0

Decimal: 8 K=8: 1000 K=8: 0000 1000

Page 57: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

57

One’s Complements Format (2/2)

To store an negative integer -K in N bits:1. Change K to binary format in N bits

2. Complement it.• Complement: change all 0s to 1s and all 1s to 0s.• Above operation is called one’s complementing an

integer.

1 1 1 0 1 1 1

Decimal: -8 K=8: 0000 1000 complement 1111 0111

1One’s complement: F7H

Page 58: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

58

1’s Complement N=3

N=3

2N-1-1=22-1=3

Range: -3 〜 3

Base 10 storage

0 000

1 001

2 010

3 011

-3 100

-2 101

-1 110

-0 111

Page 59: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

59

1’s Complement N=4

N=4

2N-1-1=23-1=7

Range: -7 〜 7

Base 10 Storage

0 0000

1 0001

2 0010

3 0011

4 0100

5 0101

6 0110

7 0111

Base 10 Storage

-7 1000

-6 1001

-5 1010

-4 1011

-3 1100

-2 1101

-1 1110

-0 1111

Page 60: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

60

Example 11

Question: Store –258 in a 16-bit memory location using one’s complement representation.

Solution: 1. -25810 25810 1 0000 00102

2. Add seven 0s to make 16 bits: 0000 0001 0000 0010

3. Complement: Result= 1111 1110 1111 1101

Page 61: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

61

Range of One’s Complement

Range of N-bit memory location:

Range: - (2N-1-1) 〜 + (2N-1-1)

Number of Bits Range

4 -7 〜 7 (1000 〜 0111)

8 -127 〜 127 (1000 0000 〜 0111 1111)

16 -32,767 〜 32,767

32 -2,147,483,647 〜 2,147,483,647

N bits

Page 62: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

62

Features of 1’s Complement (1/2)

In one’s complement representation, the leftmost bit defines the sign of the number.• If it is 0, the number is positive.• If it is 1, the number is negative.

There are two 0s in one’s complement representation: positive 0 and negative 0.

In an 8-bit allocation:+ 0 → 00000000

- 0 → 11111111

Page 63: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

63

Features of 1’s Complement (2/2)

One’s complement means reversing all bits. If you one’s complement a positive number,

you get the corresponding negative number. If you one’s complement a negative number,

you get the corresponding positive number. If you one’s complement a number twice, you

get the original number. Ex: 111111002 = -310 v.s. 000000112 = 310

Page 64: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

64

Interpretation of 1’ Complement Integers in Decimal

How do you interpret a one’s complement representation in decimal?1. If the leftmost bit is 0: (positive)

a. Change the entire number from binary to decimal.

b. Put a plus sign + in front of the number.

2. If the leftmost bit is 1: (negative)a. Complement the entire number.

b. Change the entire number from binary to decimal.

C. Put a negative sign - in front of the number.

Page 65: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

65

Example 12

Question: Interpret 11110110 in decimal if the number was stored as a one’s complement integer.

Solution: 1. 1111 0110 is negative 0000 1001 (complement)

2. Change to decimal 0000 10012 910

3. Add – sign since the leftmost bit =1

Result= - 9

Page 66: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

66

Applications of One’s Complement Format

It is not used to store signed numbers. Disadvantage:

• Operations are not easy.• There are two 0’s.

Advantage:• It is the base of 2’s complement.• It is interesting for data communication

applications such as error detection and correction.

Page 67: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

67

Questions 5

1. Store -64 in an 8-bit memory location using 1’s complement representation.

2. Interpret 10100001 in decimal if the number was stored as a 1’s complement integer.

Page 68: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

68

Two’s Complement Format (1/3)

Two’s complement is the most common, the most important, and the most widely used representation of integers today.

To store an positive integer K in N bits:• Change K to binary format.• 0’s are added to the left to the number to make a

total of N bits.

0 0 0 0 1 1 0Two’s complement: 06H

0

Decimal: 6 K=6: 110 K=6: 0000 0110

Page 69: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

69

Two’s Complements Format (2/3)

To store an negative integer -K in N bits:1. Find the one’s complement of -K.

2. Add 1 to its one’s complement.

1 1 1 1 0 1 0

Decimal: -6 K=6: 0000 0110 1’s complement 1111 1001

add 1 to it 2’s complement 1111 1010

1Two’s complement: FAH

Page 70: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

70

Two’s Complements Format (3/3)

Another method to store an negative integer -K in N bits :1. Ignore the sign. Change K to binary of N bits.

2. Leave all the rightmost 0’s and the first 1 unchanged.

3. Complement the rest of the bits.

• The above operation (in 3/2, 3/3) is called two’s complementing an integer.

Page 71: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

71

Representation -6(1)

(2)

(3)

(4)

0 1 1 0

1 0 1 0

Page 72: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

72

2’s Complement N=3

N=3

2N-1-1=22-1=3

Range: -4 〜 3

The most significant bit works as a sign bit.• 0: positive• 1: negative

Base 10 storage

0 000

1 001

2 010

3 011

-4 100

-3 101

-2 110

-1 111

Page 73: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

73

2’s Complement N=4

N=4

2N-1-1=23-1=7

Range: -8 〜 7

Base 10 Storage

0 0000

1 0001

2 0010

3 0011

4 0100

5 0101

6 0110

7 0111

Base 10 Storage

-8 1000

-7 1001

-6 1010

-5 1011

-4 1100

-3 1101

-2 1110

-1 1111

Page 74: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

74

Example 13

Question: Store –40 in a 8-bit memory location using two’s complement representation.

Solution: 1. -4010 4010 10 10002

2. Add two 0s to make 8 bits: 0010 1000

3. 1’complement 1101 0111

4. Add 1 to it:

Answer: 1101 1000

Another Method 0010 1000

1101 1000

1. copy2.complement

Page 75: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

75

Two’s Complement Format

Range of N-bit memory location:

Range: - (2N-1) 〜 + (2N-1-1)

Number of Bits Range

4 -8 〜 7 (1000 〜 0111)

8 -128 〜 127 (1000 0000 〜 0111 1111)

16 -32,768 〜 32,767

32 -2,147,483,648 〜 2,147,483,647

Page 76: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

76

Feature of 2’s Complement

There is only one 0 in two’s complement representation.

In an 8-bit allocation:+ 0 → 00000000

If you two’s complement a positive number, you get the corresponding negative number.

If you two’s complement a negative number, you get the corresponding positive number.

If you two’s complement a number twice, you get the original number.

Page 77: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

77

Interpretation of 2’s Complement Integers in Decimal

How do you interpret a two’s complement representation in decimal?1. If the leftmost bit is 0: (positive)

a. Change the entire number from binary to decimal.

b. Put a plus sign + in front of the number.

2. If the leftmost bit is 1: (negative)a. Minus the entire number by 1.

b. Complement it.

c. Change the entire number from binary to decimal.

d. Put a negative sign - in front of the number.

Page 78: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

78

Example 14

Question: Interpret 11100110 in decimal if the number was stored as a two’s complement integer.

Solution: 1. 11100110 minus 1: 1110 0101

2. Complement it: 1110 0101 0001 1010

3. Change to decimal: 0001 10102 2610

4. Add - to it: Answer: -26

Page 79: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

79

Questions 6

1. Store -64 in an 8-bit memory location using 2’s complement representation.

2. Interpret 10100001 in decimal if the number was stored as a 2’s complement integer.

Page 80: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

80

Summary of Integer Representation

Contents of Memory------------

0000000100100011010001010110011110001001101010111100110111101111

Unsigned

------------0123456789

101112131415

Sign-and-Magnitude

---------+0+1+2+3+4+5+6+7-0-1-2-3-4-5-6-7

One’sComplement

---------+0+1+2+3+4+5+6+7-7-6-5-4-3-2-1-0

Two’sComplement

--------+0+1+2+3+4+5+6+7-8-7-6-5-4-3-2-1

Page 81: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

81

Section 3.4Excess System

Page 82: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

82

Excess System

A magic number (or bias) is add to each number such that the sum is positive and can be change to binary as unsigned number.

Ex: 8-bit storage• Range -100 〜 155 → magic number = 100

Excess_100

• Range -128 〜 127 → magic number = 128Excess_128

• Range -127 〜 128 → magic number = 127Excess_127

Store the exponential value of a fraction.

Page 83: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

83

Excess_3

N=3 2N =8 number Range: -3 〜 4 Magic Number = 3

Base 10 + Magic number

Storage

-3 0 000

-2 1 001

-1 2 010

0 3 011

1 4 100

2 5 101

3 6 110

4 7 111

Page 84: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

84

Excess_127

To store an integer K in N=8 bits:• Magic number = 127

• Add magic number to K (i.e., K=K+127)The range is –127 〜 128

• Change K to binary format.

0 0 0 0 1 1 1Excess-127 representation: 87H

1

Decimal: K=8 , N=8 magic number = 127 K=K+127 =8+127=135 K=135: 1000 0111

Page 85: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

85

Excess_128

To store an integer K in N=8 bits:• Magic number = 128

• Add magic number to K (i.e., K=K+128)The range is –128 〜 127

• Change K to binary format.

0 0 0 1 0 0 0Excess-128 reprsentation:88H

1

Decimal: K=8 , N=8 magic number =128 K=K+128 =8+128=136 K=136: 1000 1000

Page 86: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

86

Example 15

Question: Represent –25 in Excess_127 using an 8-bit allocation.

Solution: 1. magic number = 127

2. -25+127= 102

3. Change to binary: 10210 Answer 0110 01102

Page 87: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

87

Interpretation of Excess Integer in Decimal

How do you interpret an excess integer representation in decimal?1. Change the number to decimal.

2. Subtract the magic number from the integer.

Page 88: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

88

Example 16

Question: Interpret 11111110 if the representation is Excess_127.

Solution:1. Change to decimal: 1111 11102 25410

2. Subtract 127 to it: Answer: 127

Page 89: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

89

Questions 7

1. Store -64 in an 8-bit memory location using Excess_127 representation.

2. Store -64 in an 8-bit memory location using Excess_128 representation.

3. Interpret 10100001 in decimal if the number was stored as an Excess_128 integer.

Page 90: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

90

Section 3.5Floating-Point Representation

Page 91: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

91

Floating-point

A floating-point number contains integer and fraction.

To represent a number, for example, +71.3125 (+1000111.0101) • Store the sign, all of the bits, and the position of the

decimal point in memory.

Page 92: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

92

Scientific Notation of Decimal

To move the radix point so that there only one digit to the left of the decimal point• Right/left movement of x positions: multiple 10-x/10x

Original Number Move Normalized

81.33 1 +101 8.133

0.00000194003 6 +10-6 1.94003

-2990.001 3 -103 2.990001

Exponent fixed-point section

Page 93: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

93

Scientific Notation of Binary

To move the radix point so that there only one 1 to the left of the decimal point• Right / left movement of x positions: multiple 2-x/2x

Original Number Move Normalized

11.11 1 +21 1.111

+1010001.11001 6 +26 1.01000111001

-111.000011 2 -22 1.11000011

+0.00000111001 6 +2-6 1.11001

-0.001110011 6 -2-3 1.110011

Exponent mantissa

Page 94: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

94

IEEE Standards for Floating-point Representation

Page 95: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

95

Examples of Floating-point Representation

Single-precision representation• Store the sign as 0 (positive) or 1 (negative).• Store the exponent (power of 2) as Excess_127.• Store the mantissa as an unsigned integer

Number Sign Exponent Mantissa

-22 1.11000011 1 10000001 1100001 10000000 00000000

+2-6 1.11001 0 01111001 1100100 00000000 00000000

-2-3 1.110011 1 01111100 1100110 00000000 00000000

Page 96: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

96

Example 17

To store a number 3.75 in 8 bits:• Change 3.75 to binary format 11.11.• Normalization to +21 1.111.• Sign: 0 for positive, 1 for negative• Exponent: Excess_3

0 1 0 0 1 1 1 0

Page 97: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

97

Example 18

Question: To store a number -8.125 in 8 bits. Solution:

• Change 8.125 to binary format 1000.001.• Normalization to -23 1.000001.• Negative: sign = 1; Excess_3: 3+3=6

1 1 1 0 0 0 0 0

Page 98: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

98

Example 19

Question: Show the representation of the normalized number - 161.875.

Solution: • -161.875 → -10100001.111 → 27 × 1.0100001111• Exponent=7 → 7+127=134 → 1000 0110• For 1.0100001111 → Mantissa = 010 0001 111

1 1000 0110 010 0001 1110 0000 0000 0000

Sign Exponent (8 bits) Mantissa (23 bits)

Page 99: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

99

Interpretation of Floating-point Number to Decimal

Interprets a 32-bit floating-point number:1. Use the left most bit as the sign.

2. Change the next 8 bits to decimal and subtract 127 from it. This is the exponent.

3. Add 1 and a decimal point to the next 23 bits.

4. Move the decimal point to the correct position using the value of the exponent.

5. Change the whole part to decimal.

6. Change the fraction part to decimal.

7. Combine the whole and the fraction parts.

Page 100: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

100

Example 20

Question: Interpret the following 32-bit floating-point number

1 01111100 11001100000000000000000 Solution:

• Sign=1: negative

• Exponent=011111002=12410 →124 - 127= -3

• Answer = - 2-31.110011 = -0.001110011

= -0.22265625

Page 101: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

101

Questions 7

1. Show the floating-point representation of the decimal number -4.5.

2. Show the floating-point representation of the decimal number 0.

3. Interpret the following 8-bit floating-point number 10111100 in decimal.

Excess_3

Page 102: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

102

Storing Zero

A real number zero, 0.0, cannot be stored using the steps discussed above.

In this special case, the sign, exponent and the mantissa are set to 0s.

Page 103: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

103

Overflow and Underflow in Floating-point Representation

An attempt to store numbers with very small absolute values results in an underflow condition.

An attempt to store numbers with very large absolute values results in an overflow condition.

+129 +129

(1 + 2-23 ) (1 + 2-23 )

Page 104: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

104

Section 3.6Hexadecimal Notation

Page 105: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

105

Hexadecimal Notation

Hexadecimal notation provides a convenient way for human reading.

00110000 → x30 or 30H

Page 106: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

106

Section 3.7Key Terms

Page 107: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

107

Key Terms (1/2)

How many terms can you describe?• Decimal system• Binary system• Decimal to binary conversion• Binary to decimal conversion• Whole number

• Integer • Fraction• Unsigned integer• Positive integer• Negative integer

Page 108: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

108

Key Terms (2/2)

How many terms can you describe?• Sign-and-magnitude representation• One’s complement representation• Two’s complement representation• Excess system• Floating-point number• Normalization• Mantissa• Exponent• Single-precision format• Double precision format

Page 109: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

109

Section 3.8Summary

Page 110: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

110

Summary (1/5)

The decimal system has 10 digits and is based on powers of 10.

The binary system, used by computers to store numbers, has 2 digits, 0 and 1, and is based on powers of 2.

The bit allocation is the number of bits used to represent an integer.

Integers can be represented as unsigned or signed numbers.

Unsigned numbers are commonly used for counting and addressing.

Page 111: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

111

Summary (2/5)

There are three major methods of signed number representations: sign-and-magnitude, one’s complements, and two’s complement.

In the sign-and-magnitude method of integer representation, 1 bit represents the sign of the number; the remaining bits represent the magnitude.

In one’s complement method of integer representation, a negative number is represented by complementing the corresponding positive number.

Page 112: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

112

Summary (3/5)

Complementing a number means to convert each 1 to 0 and 0 to 1.

In the two’s complement methods of integer representation, a negative number is represented by leaving all the rightmost 0s and the first 1 unchanged an then complementing the remaining bits.

Most computers today used the two’s complement method of integer representation.

Page 113: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

113

Summary (4/5)

Both sign-and-magnitude and one’s complement methods have two representations for the 0 value; two’s complement has just one representation for the 0 value.

A floating-point number is a whole number and a fraction. Conversion of the fraction to binary requires the denominator of the fraction to be expressed as power of 2. The Excess_X system is used to store this power of 2.

Page 114: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

114

Summary (5/5)

A fraction is normalized so that operations are simpler.

To store a fraction in memory, you need its sign, exponent, and mantissa.

Page 115: 1 Chapter 3 Number Representation. 2 Objective 在這一章中,我們將學習在電腦中使用的數字系 統:在電腦中如何用一串的 0 與 1 來表示一個數字,

115

Homework

Review Questions: 7,10,13,14,15,17 Multiple-Choice Questions: 20-46 Exercises: 47(a), 49(a,b), 52(a,b), 53(a,c),

65(a,c), 66, 70(a),74(b,c)請說明你對利用 peer-to-peer 技術的看法。