Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9124697
math-fround.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
866 B
Subscribers
None
math-fround.js
View Options
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.es/ecma262/#sec-math.fround
// eslint-disable-next-line es-x/no-math-fround -- safe
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 -- NaN check
if
(
result
>
MAX32
||
result
!=
result
)
return
$sign
*
Infinity
;
return
$sign
*
result
;
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jun 21, 7:26 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3322120
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment