double-double
Version:
Pure double-double precision functions *with strict error bounds*.
18 lines • 600 B
JavaScript
/**
* Returns the sum and exact error of adding two floating point numbers.
* Uses an EFT (error-free transformation), i.e. a+b === x+y exactly.
* The returned sum is a non-overlapping expansion (smallest value first!).
*
* Precondition: abs(a) >= abs(b) - A fast test that can be used is
* (a > b) === (a > -b)
*
* See https://people.eecs.berkeley.edu/~jrs/papers/robustr.pdf
*/
function fastTwoSum(a, b) {
const x = a + b;
return [b - (x - a), x];
}
// inlined
//const R = a + b; const r = b - (R - a); return [r, R];
export { fastTwoSum };
//# sourceMappingURL=fast-two-sum.js.map