Skip to content

Commit

Permalink
[Fix] broken hasULPDistance → working withinULPDistance helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Apr 8, 2017
1 parent 6d65367 commit 8d7aec1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions es6-shim.js
Expand Up @@ -2071,8 +2071,8 @@
}
};

var hasULPDistance = function hasULPDistance(result, expected, distance) {
return _abs(1 - (result / expected)) / Number.EPSILON > (distance || 8);
var withinULPDistance = function withinULPDistance(result, expected, distance) {
return _abs(1 - (result / expected)) / Number.EPSILON < (distance || 8);
};

defineProperties(Math, MathShims);
Expand All @@ -2093,9 +2093,9 @@
// Chrome 40 loses Math.acosh precision with high numbers
defineProperty(Math, 'acosh', MathShims.acosh, Math.acosh(Number.MAX_VALUE) === Infinity);
// Chrome < 54 has an inaccurate acosh for EPSILON deltas
defineProperty(Math, 'acosh', MathShims.acosh, !hasULPDistance(Math.acosh(1 + Number.EPSILON), Math.sqrt(2 * Number.EPSILON)));
defineProperty(Math, 'acosh', MathShims.acosh, !withinULPDistance(Math.acosh(1 + Number.EPSILON), Math.sqrt(2 * Number.EPSILON)));
// Firefox 38 on Windows
defineProperty(Math, 'cbrt', MathShims.cbrt, !hasULPDistance(Math.cbrt(1e-300), 1e-100));
defineProperty(Math, 'cbrt', MathShims.cbrt, !withinULPDistance(Math.cbrt(1e-300), 1e-100));
// node 0.11 has an imprecise Math.sinh with very small numbers
defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(-2e-17) !== -2e-17);
// FF 35 on Linux reports 22025.465794806725 for Math.expm1(10)
Expand Down

0 comments on commit 8d7aec1

Please sign in to comment.