py: Add MICROPY_FLOAT_CONST macro for defining float constants.

All float constants in the core should use this macro to prevent
unnecessary creation of double-precision floats, which makes code less
efficient.
This commit is contained in:
Damien George
2016-11-03 12:33:01 +11:00
parent ca973bd308
commit 561844f3ba
3 changed files with 7 additions and 6 deletions

View File

@@ -227,7 +227,7 @@ mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool
} else {
if (in == PARSE_DEC_IN_FRAC) {
dec_val += dig * frac_mult;
frac_mult *= 0.1;
frac_mult *= MICROPY_FLOAT_CONST(0.1);
} else {
dec_val = 10 * dec_val + dig;
}