R EPRESENTATION OF REAL NUMBER Presented by: Pawan yadav Puneet vinayak
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
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: ( whole=37, fraction = 25)
F LOATING P OINT N UMBERS For example, can be analyzed as: TensUnitsTenths Hundredths = 3 x x x 1/ x 1/100
B INARY E QUIVALENT In the binary representation of a floating point number the column values will be as follows: … … … /2 1/4 1/8 1/16 … … …
D ECIMAL B INARY CONVERSION Repeatedly multiply fraction by two until fraction becomes zero 1.0
S CIENTIFIC NOTATION OF FLOATING NUMBERS Decimal: -123,000,000,000,000 × +1.23× Binary: × × 2 -16
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: = mantissa = = –1
N ORMALIZED AND U NNORMALIZED
N ORMALIZATION P ROCESS
F LOATING P OINT F ORMAT FOR B INARY N UMBERS
IEEE F LOATING P OINT R EPRESENTATION – more exponent bits greater range – more significant bits greater accuracy
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.
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 or 132; an exponent of -5 is stored as (-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.
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: X 2 3 The mantissa is stored in a 23 bit field,
N ORMALIZING N UMBERS Example: = x = 0.21 x B =.1011 x 2 3 or x 2 2 (hidden1) B =.11 x 2 -1 or 1.1 x 2 -2 (hidden1) AB.CD H =.ABCD x AC H =.AC x Note that the concept of a hidden 1 only applied to binary.
C ONVERTING DECIMAL FLOATING POINT VALUES TO STORED IEEE STANDARD VALUES. Example : Find the IEEE FP representation of Step 1. Compute the binary equivalent of the whole part and the fractional part. ( convert 40 and to their binary equivalents) =
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 = x 2 5 Step 3. Convert the exponent to a biased exponent = 132 ==> =
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)
C ONVERT TO SINGLE PRECISION FLOATING POINT
F LOATING -P OINT A DDITION 23 Assume 4 decimal digit for mantissa
FLOATING POINT SUBTRACTION ( USING 4 DIGIT MANTISSA ) Addition must be of terms of the same scale: 10 6 {both10 6 } ( ) 10 6 {4 digit mantissa}
R EAL N UMBER M ULTIPLICATION ( USING 4 DIGIT MANTISSA ) Multiplication problem is in the mantissa ( 10 2 ) ( 10 4 ) {add indices} 10 6 = 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.
R EAL N UMBER DIVISION ( USING 4 DIGIT MANTISSA ) ( 10 2 ) /( 10 4 ) ( /0.1455) {sub indices} = {4 digit mantissa}
E RRORS IN FLOATING POINT ARITHMETIC Round off error Ex = =7.24 Truncation error = =5.4567