diff options
author | Damien George <damien.p.george@gmail.com> | 2016-01-08 17:57:30 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-01-08 17:57:30 +0000 |
commit | da3dffa79ddadbc789a06e7afd82ca6e52b47b8c (patch) | |
tree | 790d24c7687d8113d70573413ad83d6a51bad66f | |
parent | 2adf7ec3dd4da9188be60e9536b401ab99189558 (diff) | |
download | micropython-da3dffa79ddadbc789a06e7afd82ca6e52b47b8c.tar.gz micropython-da3dffa79ddadbc789a06e7afd82ca6e52b47b8c.zip |
py/objint: Fix classification of float so it works for OBJ_REPR_D.
-rw-r--r-- | py/objint.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/py/objint.c b/py/objint.c index db8eaa48d8..57fe364dcf 100644 --- a/py/objint.c +++ b/py/objint.c @@ -107,7 +107,9 @@ mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) { } else { e &= ~((1 << MP_FLOAT_EXP_SHIFT_I32) - 1); } - if (e <= ((BITS_PER_WORD + MP_FLOAT_EXP_BIAS - 3) << MP_FLOAT_EXP_SHIFT_I32)) { + // 8 * sizeof(uintptr_t) counts the number of bits for a small int + // TODO provide a way to configure this properly + if (e <= ((8 * sizeof(uintptr_t) + MP_FLOAT_EXP_BIAS - 3) << MP_FLOAT_EXP_SHIFT_I32)) { return MP_FP_CLASS_FIT_SMALLINT; } #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG |