py/formatfloat: Format all whole-number floats exactly.

Formerly, py/formatfloat would print whole numbers inaccurately with
nonzero digits beyond the decimal place.  This resulted from its strategy
of successive scaling of the argument by 0.1 which cannot be exactly
represented in floating point.  The change in this commit avoids scaling
until the value is smaller than 1, so all whole numbers print with zero
fractional part.

Fixes issue #4212.

Signed-off-by: Dan Ellis dan.ellis@gmail.com
This commit is contained in:
Dan Ellis
2022-07-12 09:48:38 -04:00
committed by Damien George
parent b22abcdbbe
commit f9cbe6bc47
7 changed files with 154 additions and 55 deletions

View File

@@ -516,6 +516,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
if upy_float_precision < 64:
skip_tests.add("float/float_divmod.py") # tested by float/float_divmod_relaxed.py instead
skip_tests.add("float/float2int_doubleprec_intbig.py")
skip_tests.add("float/float_format_ints_doubleprec.py")
skip_tests.add("float/float_parse_doubleprec.py")
if not has_complex: