aboutsummaryrefslogtreecommitdiff
path: root/py/mpz.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-07-31 13:41:43 +0000
committerDamien George <damien.p.george@gmail.com>2014-07-31 13:41:43 +0000
commitc9aa58e6381018cca2513e3468363af0b5442d1f (patch)
tree47fa6e3a4971fe4053b08bb085710c325d11bfd0 /py/mpz.h
parent94fbe9711a1179b3c4d0eb2e9822787d90231719 (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.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/mpz.h b/py/mpz.h
index c0cf60f4b..1620a434e 100644
--- a/py/mpz.h
+++ b/py/mpz.h
@@ -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