Skip to content

Commit

Permalink
Fix regression printing 0.0, fix #1953
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Oct 30, 2020
1 parent a7b3fa4 commit 9b22391
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/jsutils.c
Expand Up @@ -629,10 +629,10 @@ void ftoa_bounded_extra(JsVarFloat val,char *str, size_t len, int radix, int fra
#ifndef USE_NO_FLOATS
// check for exponents
int exponent = 0;
if (radix == 10 && (val >= 1E21 || val < 1E-6)) {
if (radix == 10 && val>0.0) {
// use repeated mul/div for ease, but to
// improve accuracy we multiply by 1e5 first
if (val>1) {
if (val >= 1E21) {
while (val>100000) {
val /= 100000;
exponent += 5;
Expand All @@ -641,7 +641,7 @@ void ftoa_bounded_extra(JsVarFloat val,char *str, size_t len, int radix, int fra
val /= 10;
exponent ++;
}
} else {
} else if (val < 1E-6) {
while (val<1E-5) {
val *= 100000;
exponent -= 5;
Expand Down

0 comments on commit 9b22391

Please sign in to comment.