This module implements the interface to part of the GNU MP library. This library contains arbitrary precision integer and rational number arithmetic routines. Only the interfaces to the integer (`mpz_<#3266#>...<#3266#>') routines are provided. If not stated otherwise, the description in the GNU MP documentation can be applied.
In general, mpz-numbers can be used just like other standard
Python numbers, e.g. you can use the built-in operators like +
,
*
, etc., as well as the standard built-in functions like
abs
, int
, ..., divmod
, pow
.
Please note: the <#3275#>bitwise-xor<#3275#> operation has been implemented as
a bunch of <#3276#>and<#3276#>s, <#3277#>invert<#3277#>s and <#3278#>or<#3278#>s, because the library
lacks an mpz_xor
function, and I didn't need one.
You create an mpz-number, by calling the function called mpz
(see
below for an excact description). An mpz-number is printed like this:
mpz(value)
.
A number of <#3290#>extra<#3290#> functions are defined in this module. Non mpz-arguments are converted to mpz-values first, and the functions return mpz-numbers.
An mpz-number has one method: