Skip to content

Commit 2599672

Browse files
committed
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.
1 parent e1e7657 commit 2599672

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

py/parsenum.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,7 @@ mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool
263263
}
264264

265265
// apply the exponent
266-
for (; exp_val > 0; exp_val--) {
267-
dec_val *= 10;
268-
}
269-
for (; exp_val < 0; exp_val++) {
270-
dec_val *= 0.1;
271-
}
266+
dec_val *= MICROPY_FLOAT_C_FUN(pow)(10, exp_val);
272267
}
273268

274269
// negate value if needed

0 commit comments

Comments
 (0)