py: Fix float to int conversion for large exponents.

This commit is contained in:
David Steinberg
2015-01-02 12:39:22 +00:00
committed by Damien George
parent ffc96a901a
commit 6e0b6d02db
4 changed files with 109 additions and 7 deletions

View File

@@ -298,9 +298,9 @@ mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) {
#if MICROPY_PY_BUILTINS_FLOAT
mp_obj_t mp_obj_new_int_from_float(mp_float_t val) {
// TODO: This doesn't handle numbers with large exponent
long long i = MICROPY_FLOAT_C_FUN(trunc)(val);
return mp_obj_new_int_from_ll(i);
mp_obj_int_t *o = mp_obj_int_new_mpz();
mpz_set_from_float(&o->mpz, val);
return o;
}
#endif