Skip to content
Snippets Groups Projects
Commit da3dffa7 authored by Damien George's avatar Damien George
Browse files

py/objint: Fix classification of float so it works for OBJ_REPR_D.

parent 2adf7ec3
No related branches found
No related tags found
No related merge requests found
...@@ -107,7 +107,9 @@ mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) { ...@@ -107,7 +107,9 @@ mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
} else { } else {
e &= ~((1 << MP_FLOAT_EXP_SHIFT_I32) - 1); 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; return MP_FP_CLASS_FIT_SMALLINT;
} }
#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment