Skip to content

Commit 5e17892

Browse files
authored
fix: Use proper portable copysign polyfill (#2490)
1 parent f9dee72 commit 5e17892

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

std/portable/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ if (typeof globalScope.ASC_TARGET === "undefined") {
140140
const INV_EPS64 = 4503599627370496.0;
141141
const y = Math.abs(value);
142142
return y < INV_EPS64
143-
? Math.abs(y + INV_EPS64 - INV_EPS64) * Math.sign(value)
143+
? (y + INV_EPS64 - INV_EPS64) * Math.sign(value)
144144
: value;
145145
};
146146

@@ -153,7 +153,9 @@ if (typeof globalScope.ASC_TARGET === "undefined") {
153153
globalScope["trunc"] = Math.trunc;
154154

155155
globalScope["copysign"] = function copysign(x, y) {
156-
return Math.abs(x) * Math.sign(y);
156+
return y
157+
? Math.abs(x) * Math.sign(y)
158+
: (F64[0] = y, U64[1] >>> 31 ? -1 : 1); // +0, -0, -NaN, +NaN
157159
};
158160

159161
globalScope["bswap"] = function bswap(value) {

0 commit comments

Comments
 (0)