Algorithm and Architecture for On-Line Decimal Powering Computation

Algorithm and Architecture for On-Line Decimal Powering Computation

Algorithm and Architecture for on-line Decimal Powering Computation Mahmoud Y. Hassan∗, Tarek ElDeeb∗ and Hossam A. H. Fahmyy ∗SilMinds, Maadi, 11431, Helwan, Egypt Email: [email protected] yElectronics and Communications Department, Cairo university, Egypt Email: [email protected] Abstract—An architecture for the computation of a decimal scheme between subsequent operations. The final result is powering function is presented in this paper. The algorithm con- faithfully rounded, that is the result is one of the immediate sists of a sequence of overlapped operations: 1) digit recurrence floating point neighbors to the exact result. To the best of logarithm, 2) sequential multiplication, and 3) on-line antiloga- rithm. A correction scheme is introduced between the overlapped the authors knowledge, this is the first work to implement a operations to guarantee correct on-line calculations. Execution decimal floating point powering function on hardware. times are estimated for decimal64 and decimal128 formats of the The paper is organized as follows: section II introduces the IEEE 754-2008 standard for floating point arithmetic. decimal powering. Section III shortly presents the testing and implementation results while section IV gives the conclusions. I. INTRODUCTION II. ALGORITHM Interest in decimal arithmetic increased considerably in The algorithm is based on the mathematical identity: recent years. There are many commercial demands for Dec- imal Floating Point (DFP) arithmetic operations such as tax XY = 10Y log10X for X > 0 (1) calculations, currency conversion and phone billing. Power- For X < 0, invalid operation is signaled out for finite non- ing (XY ) is an important function in financial applications integer Y . A negative final result is obtained for X < 0 and such as interest rate calculations. Decimal Powering function an odd integer Y . For X < 0 and an even integer Y , the final pow(x,y)= xy where x 2 [−∞; +1] and y 2 [−∞; +1] result is positive. Both inputs X and Y are decimal floating is defined in the new IEEE 754-2008 standard [1] and is point operands and their absolute values are denoted M^ 10Ex implemented in this work. The standard also defines other x and M^ 10Ey respectively. Hence, functions such as: compound(x,n)= (1 + x)n, pown(x,n)= xn y y ^ Ey ^ Ex where n is an integer, powr(x,y)= x (derived by considering XY = 10My 10 log10(Mx10 ) (2) only exp(y × log(x)) where x 2 [0; +1] and y 2 [−∞; +1]. ^ Ey ^ = 10My 10 (log10(Mx)+Ex) Most elementary functions are implemented using software ^ ^ libraries due to the advantage of using large look up tables And when both Mx and My are normalized, then and providing more accurate results. However, software algo- Ey +L XY = 10My 10 (log10(Mx)+Ex+K) (3) rithms are not suitable for numerical intensive and real time applications due to their slow operation, 100 to 1000 slower Where L is the leading zero count of M^ y and K is the integer than what can be implemented in hardware [2]. Therefore, part of the logarithm’s result when normalizing M^ x and can new algorithms and hardware implementations for elemen- be calculated by subtracting leading zero count of M^ x from its tary decimal floating point arithmetic functions have been precision. Thus, to calculate the final result, three composite introduced recently [3] [4] [5]. The accurate computation of operations have to be performed consecutively, logarithm, the floating point powering function is difficult and requires multiplication and antilogarithm. Moreover, in order to reduce wider calculating precisions as explained by the Table Maker’s the latency of the powering function, the sub operations have Dilemma [6]. A composite iterative algorithm for the compu- to be computed on-line [7]. That is, every stage starts its tation of binary powering function is introduced in [7]. In this operation based on a calculated digit in the previous stage. paper, we give a detailed description of an iterative algorithm Special data NaN, Inf and 0 are handled according to the IEEE for the computation of the decimal powering function (XY ). standard’s specifications for floating point arithmetic [1]. Three overlapped operations: logarithm, multiplication and A. Logarithm (log ) antilogarithm are done iteratively combined with a correction 10 Logarithm is computed iteratively using the digit recurrence The project ”Promoting Egypt as the first decimal Arithmetic Intellectual algorithm with selection by rounding. Pineiro et al. [8] in- property cores provider for financial applications in the world” (grant number troduced an algorithm for the computation of logarithms for C2/S1/163) is funded by the RDI Programme through the EU-Egypt Innova- tion Fund (EEIF). The RDI Programme is a programme of the Ministry of binary floating point numbers. Chen et al. [3] adapted the same Higher Education and Scientific Research funded by the European Union. algorithm to decimal floating point numbers. TABLE I LOOK UP TABLE FOR e1 SELECTION 2) Error analysis: a) Inherent Error of Algorithm: This error results from Ranges of m e1 [0:96; 1:00) 0 the difference between the logarithm result obtained from finite [0:88; 0:95] 1 iterations and the exact result obtained from infinite iterations. [0:81; 0:87] 2 Since the decimal logarithmic result is achieved after nth [0:76; 0:80] 3 [0:70; 0:75] 4 iteration, "i can be defined as: [0:66; 0:69] 5 1 X [0:62; 0:65] 6 " = − log (1 + e 10−j) (11) [0:59; 0:61] 7 i 10 j [0:56; 0:58] 8 j=n [0:50; 0:55] 9 Since ej represents the error between two successive iterations and ej 2 [−9; 9] ,we choose the worst cases (ej = 9 or − 9) to analyze maximum "i 1) Algorithm: A logarithmic result log10(x) can be 1 X −j achieved according to [3] based on the mathematical identity: "i = − log10(1 ± 9 × 10 ) (12) Y X j=n log10(m) = log10(m fj) − log10(fj) (4) According to (12), maximum "i is in the range: 1 So log (m) = − P log (f ) if the first term converges −n −n 10 j=1 10 j −4:34 × 10 ≤ "i ≤ 4:34 × 10 (13) −j to zero. fj is defined as fj = 1 + ej10 , this form allows −j ej 10 the use of a shift-and-add implementation. The corresponding b) Approximation Error: The approximate value ln(10) −j th recurrences for computing the logarithm are: is used to estimate log(1 + ej10 ) from the k to the th −j n iteration. According to the series expansion of logarithm E(j + 1) = E[j](1 + ej10 ) (5) function in (10), Since the value of log(1 + x) is approximatd L(j + 1) = L(j) − log (1 + e 10−j) (6) x th −j 10 j by ln(10) after the k iteration. Putting x = ej10 , this produces an approximation error, "a: Where, E[1] = m and L[1] = 0. The digits ej are selected so n (e 10−j )2 (e 10−j )3 that E(j + 1) converges to 1. To have a selection function for X − j + j − · · · " = 2 3 (14) ej, a scaled remainder is defined as , a ln(10) j=k W [j] = 10j(1 − E[j]) (7) Since n (e 10−j )3 X j − · · · Substituting (7) in (5) yields, 3 10−n (15) ln(10) −j+1 j=k W [j + 1] = ejW [j]10 + 10(W [j] − ej) (8) So higher order terms can be neglected with respect to And e digits are selected by rounding W [j + 1] to the −j 2 j+1 − (ej 10 ) , integer part in every iteration. 2ln(10) n −j 2 X (ej10 ) " ≈ − (16) ej+1 = round(W [j + 1]) (9) a 2ln(10) j=k The logarithmic result is achieved through sequential additions Considering the worst cases (e = 9 or − 9) we obtain the according to (6), where the values of log(1 + e 10−j) are j j maximum " : stored in a look up table. The series expansion of the logarithm a " ≤ 1:78 × 10−(2k−1) (17) function : a 2 (x − x + ::: ) c) Quantization Error: Since only those intermediate log (1 + x) = 2 (10) 10 ln(10) values who have finite precisions are operated in the hardware- oriented algorithm, three quantization errors occur. First, the is used to reduce the size of this look up table. After iteration −j logarithm results are achieved by accumulating the n-digits j = k the values of log10(1+ej10 ) can be approximated by −j st −j rounding values of −log (1 + e 10 ) from the 1 to the ej 10 10 j k th ln(10) . The selection of the value depends on achieving the k iteration. In each iteration, the maximum rounding error 2 −2j ej 10 −n −j −n of −log10(1 + ej10 ) is 0:5 × 10 therefore the maximum constraint 2ln(10) < 10 , where n is the required accurate precision to be calculated. According to [3], the value of e1 "q1 is: is obtained by look up table (I), where the input is in the k X −n range 0:5 ≤ m < 1 and the number in the range 0:1 ≤ "q1 ≤ 0:5 × 10 m < 0:5 needs to be adjusted. The adjustment can be done by j=1 multiplying the input with (2, 3 or 5) and adding a value of ≤ 0:5k × 10−n (log(2), log(3) or log(5)) to the logarithm result. ej+1 values Second, the logarithm results are achieved by accumulating are selected by rounding the scaled remainder for iterations −j −ej 10 th j ≥ 2. the n−digit rounded values of ln(10) from the k to the W [j] −ej 0 th ej e1 M n iteration.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us