Download presentation
Presentation is loading. Please wait.
Published byDamian Stokes Modified over 9 years ago
1
R EPRESENTATION OF REAL NUMBER Presented by: Pawan yadav Puneet vinayak
2
C ONTENTS :- Floating Point Numbers Decimal Binary conversion Floating point representation Mantissa Exponent Normalization IEEE Floating Point Representation Floating point airhtematic Error in floating point airthematic
3
F LOATING P OINT N UMBERS In computer science real number is also called floating point number. In the decimal system, a decimal point ( radix point ) separates the whole numbers from the fractional part Examples: 37.25 ( whole=37, fraction = 25) 123.567 10.12345678
4
F LOATING P OINT N UMBERS For example, 37.25 can be analyzed as: 10 1 10 0 10 -1 10 -2 TensUnitsTenths Hundredths 37 2 5 37.25 = 3 x 10 + 7 x 1 + 2 x 1/10 + 5 x 1/100
5
B INARY E QUIVALENT In the binary representation of a floating point number the column values will be as follows: … 2 6 2 5 2 4 2 3 2 2 2 1 2 0. 2 -1 2 -2 2 -3 2 -4 … … 64 32 16 8 4 2 1. 1/2 1/4 1/8 1/16 … … 64 32 16 8 4 2 1..5.25.125.0625…
6
D ECIMAL B INARY CONVERSION Repeatedly multiply fraction by two until fraction becomes zero. 0.8125 1.625 0.625 1.25 0.25 0.5 0.5 1.0
7
S CIENTIFIC NOTATION OF FLOATING NUMBERS Decimal: -123,000,000,000,000 -1.23 × 10 14 0.000 000 000 000 000 123 +1.23× 10 -16 Binary: 110 1100 0000 0000 1.1011× 2 14 -0.0000 0000 0000 0001 1011 -1.1101 × 2 -16
8
F LOATING P OINT N UMBER R EPRESENTATION If x is a real number then its normal form representation is: x = f Base E where f : mantissa E : exponent exponent Example: 125.32 10 = 0.12532 10 3 mantissa - 125.32 10 = - 0.12532 10 3 0.0546 10 = 0.546 10 –1
9
N ORMALIZED AND U NNORMALIZED
10
N ORMALIZATION P ROCESS
11
F LOATING P OINT F ORMAT FOR B INARY N UMBERS
12
IEEE F LOATING P OINT R EPRESENTATION – more exponent bits greater range – more significant bits greater accuracy
13
IEEE F LOATING P OINT R EPRESENTATION The first, or leftmost, field of our floating point representation will be the sign bit: 0 for a positive number, 1 for a negative number.
14
IEEE F LOATING P OINT R EPRESENTATION The second field of the floating point number will be the exponent. Since we must be able to represent both positive and negative exponents, we will use a convention which uses a value known as a bias of 127 to determine the representation of the exponent. An exponent of 5 is therefore stored as 127 + 5 or 132; an exponent of -5 is stored as 127 + (-5) OR 122. The biased exponent, the value actually stored, will range from 0 through 255. This is the range of values that can be represented by 8-bit, unsigned binary numbers.
15
IEEE F LOATING P OINT R EPRESENTATION The mantissa is the set of 0’s and 1’s to the left of the radix point of the normalized (when the digit to the left of the radix point is 1) binary number. ex:1.00101 X 2 3 The mantissa is stored in a 23 bit field,
16
N ORMALIZING N UMBERS Example: 134.15 10 = 0.13415 x 10 3 0.0021 10 = 0.21 x 10 -2 101.11 B =.1011 x 2 3 or 1.011 x 2 2 (hidden1) 0.011 B =.11 x 2 -1 or 1.1 x 2 -2 (hidden1) AB.CD H =.ABCD x 16 2 0.00AC H =.AC x 16 -2 Note that the concept of a hidden 1 only applied to binary.
17
C ONVERTING DECIMAL FLOATING POINT VALUES TO STORED IEEE STANDARD VALUES. Example : Find the IEEE FP representation of 40.15625. Step 1. Compute the binary equivalent of the whole part and the fractional part. ( convert 40 and.15625. to their binary equivalents) 40.15625 10 = 101000.00101 2
18
C ONVERTING DECIMAL FLOATING POINT VALUES TO STORED IEEE STANDARD VALUES. Step 2. Normalize the number by moving the decimal point to the right of the leftmost one. 101000.00101 = 1.0100000101 x 2 5 Step 3. Convert the exponent to a biased exponent 127 + 5 = 132 ==> 132 10 = 10000100 2
19
C ONVERTING DECIMAL FLOATING POINT VALUES TO STORED IEEE STANDARD VALUES. Step 4. Store the results from above Sign Exponent (from step 3) Mantissa ( from step 2) 0 10000100 01000001010.. 0
21
C ONVERT 10.37 TO SINGLE PRECISION FLOATING POINT
23
F LOATING -P OINT A DDITION 23 Assume 4 decimal digit for mantissa
24
FLOATING POINT SUBTRACTION ( USING 4 DIGIT MANTISSA ) Addition must be of terms of the same scale: 0.2361 10 6 - 0.1455 10 4 0.2361 10 6 - 0.001455 10 6 {both10 6 } (0.2361 - 0.001455) 10 6 0.147861 10 6 0.234645 10 6 0.2346 10 6 {4 digit mantissa}
25
R EAL N UMBER M ULTIPLICATION ( USING 4 DIGIT MANTISSA ) Multiplication problem is in the mantissa (0.2361 10 2 ) (0.1455 10 4 ) 0.2361 0.1455 10 2+4 {add indices} 0.03435255 10 6 = 0.3435255 10 5 0.3435 10 5 {4 digit mantissa} Notice that multiplication must work from the largest digit downwards since at some point the number is going to have to be truncated.
26
R EAL N UMBER DIVISION ( USING 4 DIGIT MANTISSA ) (0.2361 10 2 ) /(0.1455 10 4 ) (0.2361 /0.1455) 10 2-4 {sub indices} 1.6226804 10 -2 = 0.3435255 10 5 0.16226804 10 -1 0.1623 10 -1 {4 digit mantissa}
27
E RRORS IN FLOATING POINT ARITHMETIC Round off error Ex- 5.6999=5.7 7.238=7.24 Truncation error 4.67444444=4.674 5.45676767=5.4567
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.