aboutsummaryrefslogtreecommitdiff
path: root/node_modules/core-js/library/modules/_math-fround.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/core-js/library/modules/_math-fround.js')
-rw-r--r--node_modules/core-js/library/modules/_math-fround.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/node_modules/core-js/library/modules/_math-fround.js b/node_modules/core-js/library/modules/_math-fround.js
new file mode 100644
index 00000000..c85eb4b7
--- /dev/null
+++ b/node_modules/core-js/library/modules/_math-fround.js
@@ -0,0 +1,23 @@
+// 20.2.2.16 Math.fround(x)
+var sign = require('./_math-sign');
+var pow = Math.pow;
+var EPSILON = pow(2, -52);
+var EPSILON32 = pow(2, -23);
+var MAX32 = pow(2, 127) * (2 - EPSILON32);
+var MIN32 = pow(2, -126);
+
+var roundTiesToEven = function (n) {
+ return n + 1 / EPSILON - 1 / EPSILON;
+};
+
+module.exports = Math.fround || function fround(x) {
+ var $abs = Math.abs(x);
+ var $sign = sign(x);
+ var a, result;
+ if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
+ a = (1 + EPSILON32 / EPSILON) * $abs;
+ result = a - (a - $abs);
+ // eslint-disable-next-line no-self-compare
+ if (result > MAX32 || result != result) return $sign * Infinity;
+ return $sign * result;
+};