26 #ifndef MICROPY_INCLUDED_PY_SMALLINT_H 27 #define MICROPY_INCLUDED_PY_SMALLINT_H 34 #ifndef MP_SMALL_INT_MIN 37 #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C 39 #define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)WORD_MSBIT_HIGH) >> 1)) 40 #define MP_SMALL_INT_FITS(n) ((((n) ^ ((n) << 1)) & WORD_MSBIT_HIGH) == 0) 42 #define MP_SMALL_INT_POSITIVE_MASK ~(WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1)) 44 #elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B 46 #define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)WORD_MSBIT_HIGH) >> 2)) 47 #define MP_SMALL_INT_FITS(n) ((((n) & MP_SMALL_INT_MIN) == 0) || (((n) & MP_SMALL_INT_MIN) == MP_SMALL_INT_MIN)) 49 #define MP_SMALL_INT_POSITIVE_MASK ~(WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1) | (WORD_MSBIT_HIGH >> 2)) 51 #elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D 53 #define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)0xffffffff80000000) >> 1)) 54 #define MP_SMALL_INT_FITS(n) ((((n) ^ ((n) << 1)) & 0xffffffff80000000) == 0) 56 #define MP_SMALL_INT_POSITIVE_MASK ~(0xffffffff80000000 | (0xffffffff80000000 >> 1)) 62 #define MP_SMALL_INT_MAX ((mp_int_t)(~(MP_SMALL_INT_MIN))) 68 #endif // MICROPY_INCLUDED_PY_SMALLINT_H bool mp_small_int_mul_overflow(mp_int_t x, mp_int_t y)
mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom)
mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor)