Search code examples
floating-pointprecisionieee-754floating-accuracy

IEEE 754: Where "the rounded result is within 0.5 ULP of the mathematically exact result" implication can be seen?


From ULP Wikipedia's page (emphasis added):

The IEEE 754 specification—followed by all modern floating-point hardware—requires that the result of an elementary arithmetic operation (addition, subtraction, multiplication, division, and square root since 1985, and FMA since 2008) be correctly rounded, which implies that in rounding to nearest, the rounded result is within 0.5 ULP of the mathematically exact result, using John Harrison's definition;

Question: Where exactly the implication emphasized above can be seen?


Solution

  • ... that in rounding to nearest, the rounded result is within 0.5 ULP of the mathematically exact result, using John Harrison's definition;

    Where exactly the implication emphasized above can be seen?

    Near powers-of-2. (or whatever base)

    Consider using ULP as quantum vs. John Harrison's definition.

    In a neighborhood of a power-of-2 as p and its least encoded FP digit as u, the representable floating point values are [p-u, p-u/2, p, p+u, p+2u] for a base 2 system.

    With quantum, the ULP of those 5 values are [u/2, u/2, u, u, u].

    If the exact answer to some math operation is exactly p, then p "within 0.5 ULP " includes [p-u/2, p], thus allowing the inferior p-u/2 as an acceptable answer.

    With John Harrison, the ULP of those 5 values are [u/2, u/2, u/2, u, u].

    The ULP of a value p as a power-of-2 is half as big as with quantum and so only p is an acceptable answer.


    Ref: Unit in the Last Place - ULP