Browse Source

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.
pull/1945/head
Damien George 9 years ago
parent
commit
2599672384
  1. 7
      py/parsenum.c

7
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 // apply the exponent
for (; exp_val > 0; exp_val--) { dec_val *= MICROPY_FLOAT_C_FUN(pow)(10, exp_val);
dec_val *= 10;
}
for (; exp_val < 0; exp_val++) {
dec_val *= 0.1;
}
} }
// negate value if needed // negate value if needed

Loading…
Cancel
Save