twoSumError
twoSumError(
a,b,sum):number
Defined in: two-sum.ts:22
The exact rounding error of sum, where sum is the binary64 result of a + b — so a + b === sum + twoSumError(a, b, sum) with no error at all.
Knuth’s two-sum, one of the error-free transformations: floating-point
addition throws away the bits that did not fit, and this recovers them. Six
additions, no branch, no allocation, and no ordering requirement on a and
b.
The caller passes sum rather than receiving it because JavaScript has no
multiple return values, and an object or tuple would allocate on every call —
unacceptable in the per-element loops this exists for.
Exact whenever sum is finite. If a + b overflowed there is no error term
to recover and the result is NaN.
Parameters
Section titled “Parameters”number
First term, exactly as passed to the addition.
number
Second term, exactly as passed to the addition.
number
The binary64 result of a + b.
Returns
Section titled “Returns”number
The part of a + b that sum dropped.