double-double implementation resilient to FPU rounding mode

前端 未结 1 591
独厮守ぢ
独厮守ぢ 2020-12-11 12:08

Context: double-double arithmetic

“Double-double” is a representation of numbers as the sum of two double-precision numbers without overlap in the significands. Thi

相关标签:
1条回答
  • 2020-12-11 12:54

    The article referred to by njuffa offers the function below, with very similar notations to those of my question, except that what is denoted fl (a+b) there is simply denoted a+b in my question:

    Two−Sum−toward−zero2 (a, b)
    
    if (|a| < |b|)
      swap (a , b)
    s = fl (a + b)
    d = fl (s − a)
    e = fl (b − d)
    if(|2 ∗ b|<|d|)
      s = a, e = b
    return (s, e)
    

    This is a very neat fix for this particular elementary computation when in round-toward-zero mode. It makes one hope that something would be possible for implementing a correctly rounded elementary function, at the very least by testing the rounding mode early and picking separate algorithms, or perhaps by writing very careful code that works for all rounding modes.

    0 讨论(0)
提交回复
热议问题