1 var sign = require('../internals/math-sign');
5 var EPSILON = pow(2, -52);
6 var EPSILON32 = pow(2, -23);
7 var MAX32 = pow(2, 127) * (2 - EPSILON32);
8 var MIN32 = pow(2, -126);
10 var roundTiesToEven = function (n) {
11 return n + 1 / EPSILON - 1 / EPSILON;
14 // `Math.fround` method implementation
15 // https://tc39.es/ecma262/#sec-math.fround
16 // eslint-disable-next-line es/no-math-fround -- safe
17 module.exports = Math.fround || function fround(x) {
21 if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
22 a = (1 + EPSILON32 / EPSILON) * $abs;
23 result = a - (a - $abs);
24 // eslint-disable-next-line no-self-compare -- NaN check
25 if (result > MAX32 || result != result) return $sign * Infinity;
26 return $sign * result;