diff options
Diffstat (limited to 'py/objint_longlong.c')
-rw-r--r-- | py/objint_longlong.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/py/objint_longlong.c b/py/objint_longlong.c index 28d415e69e..f10e46447b 100644 --- a/py/objint_longlong.c +++ b/py/objint_longlong.c @@ -223,9 +223,9 @@ mp_obj_t mp_obj_new_int(mp_int_t value) { } mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) { - // SMALL_INT accepts only signed numbers, of one bit less size - // than word size, which totals 2 bits less for unsigned numbers. - if ((value & (WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1))) == 0) { + // SMALL_INT accepts only signed numbers, so make sure the input + // value fits completely in the small-int positive range. + if ((value & ~MP_SMALL_INT_POSITIVE_MASK) == 0) { return MP_OBJ_NEW_SMALL_INT(value); } return mp_obj_new_int_from_ll(value); |