mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Fix Math.round for numbers > 32 bit (fix #1485)
This commit is contained in:
parent
349a09241c
commit
03f929e3e4
@ -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
|
||||
|
||||
@ -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{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user