Skip to content

Commit

Permalink
Fix bad trailing zeros when sigfigs are smaller than whole part
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Oct 2, 2024
1 parent 5d8c4ca commit fbc415a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/obj_long.c
Original file line number Diff line number Diff line change
Expand Up @@ -2761,11 +2761,11 @@ KrkValue krk_double_to_string(double a, unsigned int digits, char formatter, int
/* Small number but we have digits on or before the rounding point */
if (round_to(str, len, actual, digits - missing_digits)) missing_digits--;
actual = digits - missing_digits;
} else if (!missing_digits && actual - whole_digits > digits) {
} else if (!missing_digits && actual > whole_digits + digits) {
/* Number with no missing digits but still space for rounding */
if (round_to(str, len, actual, digits + whole_digits)) whole_digits++;
actual = digits + whole_digits;
} else if (actual == (size_t)whole_digits) {
} else if (actual <= (size_t)whole_digits) {
/* Number with no significant fractional part */
missing_digits = digits;
} else {
Expand Down

0 comments on commit fbc415a

Please sign in to comment.