Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5 Floating Point Numbers. Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer.

Similar presentations


Presentation on theme: "Chapter 5 Floating Point Numbers. Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer."— Presentation transcript:

1 Chapter 5 Floating Point Numbers

2 Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer values in the computer. l OR when the number contains a decimal fraction.

3 Real Numbers -0.35790 x 10 +6 l -357,900 l -357,903 l -35.790 x 10 +4 l -0.00357 x 10 +8

4 Scientific Notation -0.35790 x 10 +6 l Mantissa: 35790 l Sign of the Mantissa: - l Base of the Exponent: 10 l Sign of the Exponent: + l Magnitude of the Exponent: 6 l Location of Decimal (base) Point

5 Floating Point Format A single word is formatted to represent all components of the scientific notation: l Mantissa l Sign of the Mantissa l Sign of the Exponent l Magnitude of the Exponent NOTE: The base of the exponent and the location of the decimal point are fixed.

6 Typical Floating Point Format

7 Observations l Mantissa is stored using signed magnitude l First bit is the sign of mantissa l No provision for sign of the exponent => a method is needed that includes sign of exponent within exponent value

8 Excess-N Representation l To represent exponent and sign, a technique similar to the complement representation is used. l Thus, values representing exponent are divided into two sets - one representing negative exponents and the other, positive

9 Excess-50 Representation

10 Range of Values Assuming the decimal point is at the beginning of 5-digit mantissa, then the values represented range from 0.10000 x 10 -50 to 0.99999 x 10 +49 NOTE: Most significant digit is generally not zero.

11 Overflow / Underflow

12 Examples: FP to Decimal l +5324657+0.24657 x 10 +3 l -4810000 -0.1 x 10 -2 l -5555555 -0.55555 x 10 +5 l +4925000 +0.25 x 10 -1

13 Examples: Decimal to FP l 246.80650.24681 x 10 +3 +5324681 l 1255 x 10 -3 0.1255 x 10 +1 +5112550 l -0.00000075 -0.75 x 10 -6 -4475000

14 Typical FP Representation in Computers

15 Observations l Excess-128 Notation: 2 -128 to 2 +127 l 23 bits for mantissa l Trick to achieve 24-bit representation (that is, 7 decimal digits): Since MSD is to be a 1, then assume such without specification. Problems: 0, some loss of very small numbers

16 IBM FP Format NOTE: Exponent is base 16

17 Packed Decimal Format


Download ppt "Chapter 5 Floating Point Numbers. Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer."

Similar presentations


Ads by Google