1 module 2: floating-point representation. 2 floating point numbers ■ significant x base exponent...

31
1 Module 2: Floating-Point Representation

Upload: bernice-wells

Post on 22-Dec-2015

222 views

Category:

Documents


1 download

TRANSCRIPT

1

Module 2:Floating-Point Representation

2

Floating Point Numbers

■ Significant x base exponent

■ Example:

3

Example1

Fixed point Floating point

Significant/fraction Base/Radix Exponent

4

Normalized and Unnormalized■ A floating point number is said to be normalized if the

number after the radix point is a non-zero that is, it is not a ‘0’ value.

■ Unnormalized floating number is when the number after the radix point is ‘0’.

■ Example: normalized

unnormalized

unnormalized

normalized

5

Normalization Process■ Normalization is the process of deleting the zeroes until

a non-zero value is detected.

■ Example :

■ A rule of thumb:– moving the radix point to the right subtract exponent – moving the radix point to the left add exponent

6

Example 2

Decimal

Binary

-

-

7

Floating Point Format for Binary Numbers

■ General form:

■ In binary:

sign signExponent

8

Biased Exponent■ To eliminate the sign for the exponent value that is the

exponent will be positive.

sign Biased exponent

9

Conversion to Floating Point Number

■ Normalized the number

■ Change the number to biased exponent

■ Form the word (3 fields)

10

Example 3■ Transform –33.625 to floating point word using the following format (radix

2)

■ The biased constant

11

Floating-Point Representation

12

Overflow and Underflow

13

Normalized Scientific Notation

14

IEEE 754 Floating-Point Standard

15

IEEE 754 Encoding ofFloating-Point Numbers

■ Purpose of NaNs is to allow programmers to postpone some tests and decision a later time in the program when it is convenient.

16

Challenge of Negative Exponents■ Placing the exponent before the significand simplifies sorting of

floating-point numbers using integer comparison instructions.

■ However, using 2’s complement in the exponent field makes a negative exponent look like a big number.

17

Biased Notation

18

Convert 10.4ten to single precision floating point

IEEE 754 Conversion : Example 1

19

IEEE 754 Conversion : Example 2

-0.75 = -0.11

20

IEEE 754 Conversion : Example 2

21

Converting Binary to Decimal Floating-Point

Fraction = 0.01b = 0.25

22

Module 2:Floating-Point Operations

23

Floating-Point Addition Flows

24

Decimal Floating-Point AdditionAssume 4 decimal digit for significand and 2 decimal digits for exponent

25

Binary Floating-Point Addition

26

Floating-Point Multiplication Flows

27

Decimal Floating-Point MultiplicationAssume 4 decimal digit for significand and 2 decimal digits for exponent

28

Binary Floating-Point Multiplication

29

Floating-Point ALU

010 1 0 1

Control

Small ALU

Big ALU

Sign Exponent Significand Sign Exponent Significand

Exponentdifference

Shift right

Shift left or right

Rounding hardware

Sign Exponent Significand

Increment ordecrement

0 10 1

Shift smallernumber right

Compareexponents

Add

Normalize

Round

30

Accurate Arithmetic

31

… Accurate Arithmetic