diff options
author | Damien George <damien.p.george@gmail.com> | 2014-07-31 13:41:43 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-07-31 13:41:43 +0000 |
commit | c9aa58e6381018cca2513e3468363af0b5442d1f (patch) | |
tree | 47fa6e3a4971fe4053b08bb085710c325d11bfd0 /py/mpz.h | |
parent | 94fbe9711a1179b3c4d0eb2e9822787d90231719 (diff) |
py: Improve handling of long-int overflow.
This removes mpz_as_int, since that was a terrible function (it
implemented saturating conversion).
Use mpz_as_int_checked and mpz_as_uint_checked. These now work
correctly (they previously had wrong overflow checking, eg
print(chr(10000000000000)) on 32-bit machine would incorrectly convert
this large number to a small int).
Diffstat (limited to 'py/mpz.h')
-rw-r--r-- | py/mpz.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -97,8 +97,8 @@ mpz_t *mpz_div(const mpz_t *lhs, const mpz_t *rhs); mpz_t *mpz_mod(const mpz_t *lhs, const mpz_t *rhs); mp_int_t mpz_hash(const mpz_t *z); -mp_int_t mpz_as_int(const mpz_t *z); bool mpz_as_int_checked(const mpz_t *z, mp_int_t *value); +bool mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value); #if MICROPY_PY_BUILTINS_FLOAT mp_float_t mpz_as_float(const mpz_t *z); #endif |