Fix Math.round for numbers > 32 bit (fix #1485)

This commit is contained in:
Gordon Williams 2018-08-07 17:30:12 +01:00
parent 349a09241c
commit 03f929e3e4
2 changed files with 3 additions and 2 deletions

View File

@ -52,6 +52,7 @@
nRF52: NRF.requestDevice now resolves as soon as a device is found. Faster and better in congested areas
Replace use of obsolete 'usleep' function in Linux builds (fix #1455)
Add Ethernet.getIP/setIP callbacks for Wiznet to bring them in line with WiFi (fix #1482)
Fix Math.round for numbers > 32 bit (fix #1485)
1v99 : Increase jslMatch error buffer size to handle "UNFINISHED TEMPLATE LITERAL" string (#1426)
nRF5x: Make FlashWrite cope with flash writes > 4k

View File

@ -325,10 +325,10 @@ double jswrap_math_pow(double x, double y) {
JsVar *jswrap_math_round(double x) {
if (!isfinite(x) || isNegativeZero(x)) return jsvNewFromFloat(x);
x += (x<0) ? -0.4999999999 : 0.4999999999;
JsVarInt i = (JsVarInt)x;
long long i = (long long)x;
if (i==0 && (x<0))
return jsvNewFromFloat(-0.0); // pass -0 through
return jsvNewFromInteger(i);
return jsvNewFromLongInteger(i);
}
/*JSON{