summaryrefslogtreecommitdiffstatshomepage
path: root/tests/float/float_parse.py
diff options
context:
space:
mode:
authorYoctopuce dev <dev@yoctopuce.com>2025-01-30 10:23:06 +0100
committerDamien George <damien@micropython.org>2025-02-28 13:35:12 +1100
commit5fdd249c55d44ed0513e931c9b7364dd8b3454d9 (patch)
tree7ed451b4800fc10ad14cb0e91b3473a612ed0005 /tests/float/float_parse.py
parent50fab08e6b861adf65905d6adacd74201c87ddb9 (diff)
downloadmicropython-5fdd249c55d44ed0513e931c9b7364dd8b3454d9.tar.gz
micropython-5fdd249c55d44ed0513e931c9b7364dd8b3454d9.zip
py/parsenum: Reduce code footprint of mp_parse_num_float.
The mantissa parsing code uses a floating point variable to accumulate digits. Using an `mp_float_uint_t` variable instead and casting to `mp_float_t` at the very end reduces code size. In some cases, it also improves the rounding behaviour as extra digits are taken into account by the int-to-float conversion code. An extra test case handles the special case where mantissa overflow occurs while processing deferred trailing zeros. Signed-off-by: Yoctopuce dev <dev@yoctopuce.com>
Diffstat (limited to 'tests/float/float_parse.py')
-rw-r--r--tests/float/float_parse.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/float/float_parse.py b/tests/float/float_parse.py
index de27c33e7b..6131da0a63 100644
--- a/tests/float/float_parse.py
+++ b/tests/float/float_parse.py
@@ -31,6 +31,9 @@ print(float("1e-4294967301"))
print(float("1e18446744073709551621"))
print(float("1e-18446744073709551621"))
+# mantissa overflow while processing deferred trailing zeros
+print(float("10000000000000000000001"))
+
# check small decimals are as close to their true value as possible
for n in range(1, 10):
print(float("0.%u" % n) == n / 10)