Skip to content

Commit

Permalink
Fix (Number.toFixed) rounding, eg (1234.505).toFixed(2)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Aug 27, 2019
1 parent 552fb8f commit 3c700f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
@@ -1,4 +1,5 @@
Add Array.includes
Fix (Number.toFixed) rounding, eg (1234.505).toFixed(2)

2v04 : Allow \1..\9 escape codes in RegExp
ESP8266: reading storage is not working for boot from user2 (fix #1507)
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils.c
Expand Up @@ -643,7 +643,7 @@ void ftoa_bounded_extra(JsVarFloat val,char *str, size_t len, int radix, int fra
bool hasPt = false;
val*=radix;
while (((fractionalDigits<0) && (fractionalDigits>-12) && (val > stopAtError)) || (fractionalDigits > 0)) {
int v = (int)(val+((fractionalDigits==1) ? 0.4 : 0.00000001) );
int v = (int)(val+((fractionalDigits==1) ? 0.5 : 0.00000001) );
val = (val-v)*radix;
if (v==radix) v=radix-1;
if (!hasPt) {
Expand Down

0 comments on commit 3c700f9

Please sign in to comment.