mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
27 lines
804 B
JavaScript
27 lines
804 B
JavaScript
|
var sign = require('../internals/math-sign');
|
||
|
|
||
|
var abs = Math.abs;
|
||
|
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;
|
||
|
};
|
||
|
|
||
|
// `Math.fround` method implementation
|
||
|
// https://tc39.github.io/ecma262/#sec-math.fround
|
||
|
module.exports = Math.fround || function fround(x) {
|
||
|
var $abs = 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;
|
||
|
};
|