diff options
author | Damien George <damien.p.george@gmail.com> | 2018-03-01 16:02:59 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-03-01 16:02:59 +1100 |
commit | 7b050fa76c6a763043739d40c82dde839d7f8fd9 (patch) | |
tree | 8ebe60cfaf1b7c9cf7e1e1dad7a28c33f7432d27 /tests/float/float_format.py | |
parent | bc12eca461a317df842ce2e616afa97670cd0ce3 (diff) | |
download | micropython-7b050fa76c6a763043739d40c82dde839d7f8fd9.tar.gz micropython-7b050fa76c6a763043739d40c82dde839d7f8fd9.zip |
py/formatfloat: Fix case where floats could render with a ":" character.
Prior to this patch, some architectures (eg unix x86) could render floats
with a ":" character in them, eg 1e+39 would come out as ":e+38" (":" is
just after "9" in ASCII so this is like 10e+38). This patch fixes some of
these cases.
Diffstat (limited to 'tests/float/float_format.py')
-rw-r--r-- | tests/float/float_format.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/float/float_format.py b/tests/float/float_format.py index 4d5ad1d693..cda395ce02 100644 --- a/tests/float/float_format.py +++ b/tests/float/float_format.py @@ -9,3 +9,7 @@ for val in (116, 1111, 1234, 5010, 11111): # make sure rounding is done at the correct precision for prec in range(8): print(('%%.%df' % prec) % 6e-5) + +# check certain cases that had a digit value of 10 render as a ":" character +print('%.2e' % float('9' * 51 + 'e-39')) +print('%.2e' % float('9' * 40 + 'e-21')) |