Author: Armin Rigo <ar...@tunes.org> Branch: gmp Changeset: r48271:b396542050a4 Date: 2011-10-20 17:31 +0200 http://bitbucket.org/pypy/pypy/changeset/b396542050a4/
Log: Next function. diff --git a/pypy/rlib/_rbigint_gmp.py b/pypy/rlib/_rbigint_gmp.py --- a/pypy/rlib/_rbigint_gmp.py +++ b/pypy/rlib/_rbigint_gmp.py @@ -72,6 +72,15 @@ "NOT_RPYTHON" return int(_str_base_10(r)) + def touint(r): + if mpz_fits_ulong_p(r.mpz): + return mpz_get_ui(r.mpz) + elif XXX + mpz_sgn(r.mpz) < 0: + raise ValueError("cannot convert negative integer to unsigned int") + else: + raise OverflowError( + "long int too large to convert to unsigned int") + def _binary(opname): mpz_op = globals()['mpz_' + opname] def operation(r1, r2): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit