main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
732 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var sign = require('../internals/math-sign');
|
---|
3 | var roundTiesToEven = require('../internals/math-round-ties-to-even');
|
---|
4 |
|
---|
5 | var abs = Math.abs;
|
---|
6 |
|
---|
7 | var EPSILON = 2.220446049250313e-16; // Number.EPSILON
|
---|
8 |
|
---|
9 | module.exports = function (x, FLOAT_EPSILON, FLOAT_MAX_VALUE, FLOAT_MIN_VALUE) {
|
---|
10 | var n = +x;
|
---|
11 | var absolute = abs(n);
|
---|
12 | var s = sign(n);
|
---|
13 | if (absolute < FLOAT_MIN_VALUE) return s * roundTiesToEven(absolute / FLOAT_MIN_VALUE / FLOAT_EPSILON) * FLOAT_MIN_VALUE * FLOAT_EPSILON;
|
---|
14 | var a = (1 + FLOAT_EPSILON / EPSILON) * absolute;
|
---|
15 | var result = a - (a - absolute);
|
---|
16 | // eslint-disable-next-line no-self-compare -- NaN check
|
---|
17 | if (result > FLOAT_MAX_VALUE || result !== result) return s * Infinity;
|
---|
18 | return s * result;
|
---|
19 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.