Computing Correctly Rounded Integer Powers in Floating-Point Arithmetic ∗ Peter Kornerup Christoph Lauter Nicolas Louvet Vincent Lefèvre Jean-Michel Muller † May 12, 2008 Abstract We introduce several algorithms for accurately evaluating powers to a positive in- teger in floating-point arithmetic, assuming a fused multiply-add (fma) instruction is available. We aim at always obtaining correctly-rounded results in round-to-nearest mode, that is, our algorithms return the floating-point number that is nearest the exact value. 1 Introduction We deal with the implementation of the integer power function in floating-point arith- metic. In the following, we assume a radix-2 floating-point arithmetic that follows the IEEE-754 standard for floating-point arithmetic. We also assume that a fused multiply- and-add (fma) operation is available, and that the input as well as the output values of the power function are not subnormal numbers, and are below the overflow threshold (so that we can focus on the powering of the significands only). An fma instruction allows one to compute ax ± b, where a, x and b are floating-point numbers, with one final rounding only. Examples of processors with an fma are the IBM PowerPC and the Intel/HP Itanium [7]. An important case dealt with in the paper is the case when an internal format, wider than the target format, is available. For instance, to guarantee – in some cases – correctly rounded integer powers in double precision arithmetic using our algorithms based on iterated products, we will have to assume that a double-extended precision is available. The examples will consider that it has a 64-bit precision, which is the minimum required by the IEEE-754 standard. The only example of currently available processor with an fma and a double-extended precision format is Intel and HP’s Itanium Processor [22, 7]. And yet, since the fma * This is Research Report No RR-2008-15 of Laboratoire LIP. LIP is a joint laboratory of CNRS, École Normale Supérieure de Lyon, INRIA and Université de Lyon † Peter Kornerup is with SDU, Odense, Denmark; Vincent Lefèvre, Christoph Lauter, Nicolas Louvet and Jean-Michel Muller are with Laboratoire LIP, CNRS/ENS Lyon/INRIA/Université de Lyon, Lyon, France. 1 ensl-00278430, version 1 - 13 May 2008