Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add explanation about why it's safe to strip trailing zeros
  • Loading branch information
mdickinson committed May 26, 2020
commit e9a13a1d4c6f384ab2e4f7e069e77b8fecd38f9c
5 changes: 5 additions & 0 deletions Python/dtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,11 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
to surplus trailing zeros in some cases.
See bugs.python.org/issue40780. */
else {
/* At the beginning of the for loop we have 10**k <= d; it
follows that on the first iteration, ds <= dval(&u), and
so the first digit written to s is nonzero and it's safe
to strip trailing zeros. */
assert(k_check == 0);
while(*--s == '0');
s++;
}
Expand Down