UNPKG

538 BJavaScriptView Raw
1'use strict';
2var floatRound = require('../internals/math-float-round');
3
4var FLOAT32_EPSILON = 1.1920928955078125e-7; // 2 ** -23;
5var FLOAT32_MAX_VALUE = 3.4028234663852886e+38; // 2 ** 128 - 2 ** 104
6var FLOAT32_MIN_VALUE = 1.1754943508222875e-38; // 2 ** -126;
7
8// `Math.fround` method implementation
9// https://tc39.es/ecma262/#sec-math.fround
10// eslint-disable-next-line es/no-math-fround -- safe
11module.exports = Math.fround || function fround(x) {
12 return floatRound(x, FLOAT32_EPSILON, FLOAT32_MAX_VALUE, FLOAT32_MIN_VALUE);
13};