aboutsummaryrefslogtreecommitdiff
path: root/py/parsenum.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-03-29 22:12:07 +0100
committerDamien George <damien.p.george@gmail.com>2016-03-29 22:12:07 +0100
commit259967238423f2b11479dadbab6eae77cd038096 (patch)
tree7c9c3d5ed1b55d0fa52eec77b79147ee9305555d /py/parsenum.c
parente1e7657277f0c3ea6a207fa7768110475a52c39c (diff)
py/parsenum: Use pow function to apply exponent to decimal number.
Pow is already a dependency when compiling with floats, so may as well use it here to reduce code size and speed up the conversion for most cases.
Diffstat (limited to 'py/parsenum.c')
-rw-r--r--py/parsenum.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/py/parsenum.c b/py/parsenum.c
index 0915098d6..83a6abd20 100644
--- a/py/parsenum.c
+++ b/py/parsenum.c
@@ -263,12 +263,7 @@ mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool
}
// apply the exponent
- for (; exp_val > 0; exp_val--) {
- dec_val *= 10;
- }
- for (; exp_val < 0; exp_val++) {
- dec_val *= 0.1;
- }
+ dec_val *= MICROPY_FLOAT_C_FUN(pow)(10, exp_val);
}
// negate value if needed