Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions std/portable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ if (typeof globalScope.ASC_TARGET === "undefined") {

globalScope["floor"] = Math.floor;

// Adopt code from https://github.com/rfk/wasm-polyfill
globalScope["nearest"] = function nearest(value) {
if (Math.abs(value - Math.trunc(value)) === 0.5) {
return 2.0 * Math.round(value * 0.5);
}
return Math.round(value);
const INV_EPS64 = 4503599627370496.0;
const y = Math.abs(value);
return y < INV_EPS64
? Math.abs(y + INV_EPS64 - INV_EPS64) * Math.sign(value)
: value;
};

globalScope["select"] = function select(ifTrue, ifFalse, condition) {
Expand Down