UNIVERSITY OF MASSACHUSETTS Dept of Electrical Computer Engineering Digital Computer Arithmetic CE666 Koren Part 4a 1 ECE 666 Part 4 A Floating Point Arithmetic Israel Koren Spring 2008 Copyright 2008 Koren Preliminaries Representation Floating point numbers provide a dynamic range of representable real numbers without having to scale the operands Representation similar to scientific notation Two parts significand or mantissa M and exponent or characteristic E The floating point number F represented by the pair M E has the value F M E base of exponent Base common to all numbers in a given system implied not included in the representation of a floating point number CE666 Koren Part 4a 2 Copyright 2008 Koren Preliminaries Precision n bits partitioned into two parts significand M and exponent E n bits 2 ndifferent values Range between smallest and largest representable values increases distance between any two consecutive values increases Floating point numbers sparser than fixed point numbers lower precision Real number between two consecutive floating point numbers is mapped onto one of the two A larger distance between two consecutive numbers results in a lower precision of representation CE666 Koren Part 4a 3 Copyright 2008 Koren Formats Significand M and exponent E signed quantities Exponent usually a signed integer Significand usually one of two pure fraction or a number in the range 1 2 for 2 Representing negative values can be different Until 1980 no standard every computer system had its own representation method transporting programs data between two different computers was very difficult IEEE standard 754 is now used in most floating point arithmetic units details later Few computer systems use formats differing in partitioning of the n bits representation of each part or value of the base CE666 Koren Part 4a 4 Copyright 2008 Koren Significand Field Common case signed magnitude fraction Floating point format sign bit S e bits of exponent E m bits of unsigned fraction M m e 1 n Value of S E M 1 1 0 1 1 1 Maximal value Mmax 1 ulp ulp Unit in the last position weight of the leastsignificant bit of the fractional significand Usually not always ulp 2 m CE666 Koren Part 4a 5 Copyright 2008 Koren The Base k is restricted to 2 k 1 2 simplifies decreasing significand and increasing exponent and vice versa at the same time Necessary when an arithmetic operation results in a significand larger than Mmax 1ulp significand is reduced and exponent increased value remains unchanged Smallest increase in E is 1 M a simple arithmetic shift right operation if is an integral power of radix If r 2 shifting significand to the right by a single position must be compensated by adding 1 to exponent CE666 Koren Part 4a 6 Copyright 2008 Koren Example 100 Result of an arithmetic operation 01 10100 2 significand larger than Mmax Significand reduced by shifting it one position to the right exponent increased by 101 1 k New result 0 11010 2 If 2 changing exponent by 1 is equivalent to shifting significand by k positions2 010 only k position 011 Consequently shifts are allowed If 4 2 4 CE666 Koren Part 4a 7 0 01101 4 01 10100 Copyright 2008 Koren Normalized Form Floating point representation not unique 110 0 11010 2101 0 01101 2 With E 111 significand 0 00110 loss of a significant digit Preferred representation one with no leading zeros maximum number of significant digits normalized form Simplifies comparing floating point numbers a larger exponent indicates a larger number significands compared only for equal exponents k For 2 significand normalized if there is a nonzero bit in the first k positions 101 Example Normalized form of 0 00000110 100 16 is 0 01100000 16 CE666 Koren Part 4a 8 Copyright 2008 Koren Range of Normalized Fractions Range of significand is smaller than 0 1ulp Smallest and largest allowable values are Mmin 1 Mmax 1 ulp Range of normalized fractions does not include the value zero a special representation is needed A possible representation for zero M 0 and any exponent E E 0 is preferred representation of zero in floating point is identical to representation in fixed point Execution of a test for zero instruction simplified CE666 Koren Part 4a 9 Copyright 2008 Koren Representation of Exponents Most common representation biased exponent true E E bias bias constant Etrue the true value of the exponent represented in two s complement Exponent field e bits range e 1 Bias usually selected as magnitude of most negative exponent 2 e 1 Exponent represented in the excess 2 method Advantages When comparing two exponents for add subtract operations sign bits ignored comparison like unsigned numbers Floating points with S E M format are compared like binary integers in signed magnitude representation Smallest representable number has the exponent 0 CE666 Koren Part 4a 10 Copyright 2008 Koren Example Excess 64 e 7 Range of exponents in two s complement true representation is 64 E 63 1000000 and 0111111 represent 64 and 63 When adding bias 64 the true values 64 and 63 are represented by 0000000 and 1111111 This is called excess 64 representation Excess 2e 1 representation can be obtained by Inverting sign bit of two s complement representation or Letting the values 0 and 1 of the sign bit indicate negative and positive numbers respectively CE666 Koren Part 4a 11 Copyright 2008 Koren Range of Normalized Floating Point Numbers Identical subranges for positive F and negative F numbers Emin Emax smallest largest exponent An exponent larger than Emax smaller than Emin must result in an exponent overflow underflow indication Significand normalized overflow reflected in exponent Ways of indicating overflow Using a special representation of infinity as result stopping computation and interrupting processor setting result to largest representable number Indicating underflow Representation of zero is used for result and an underflow flag is raised computation can proceed if appropriate without interruption CE666 Koren Part 4a 12 Copyright 2008 Koren Range of Floating Point Numbers Zero is not included in the range of either F or F CE666 Koren Part 4a 13 Copyright 2008 Koren Example IBM 370 Short floating point format 32 bits 16 Emin Emax represented by 0000000 1111111 value of 64 63 Significand six hexadecimal digits Normalized significand satisfies Consequently CE666 Koren Part 4a 14 Copyright 2008 Koren Numerical Example IBM 370 S E M C1200000 16 in the short IBM format first byte is 11000001 2 Sign bit
View Full Document
Unlocking...