summaryrefslogtreecommitdiffstats
path: root/Doc/libmpz.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/libmpz.tex')
-rw-r--r--Doc/libmpz.tex44
1 files changed, 27 insertions, 17 deletions
diff --git a/Doc/libmpz.tex b/Doc/libmpz.tex
index 1c4b19f..707a3a8 100644
--- a/Doc/libmpz.tex
+++ b/Doc/libmpz.tex
@@ -1,38 +1,48 @@
-\section{Built-in Module \sectcode{mpz}}
+\section{Built-in Module \module{mpz}}
\label{module-mpz}
\bimodindex{mpz}
This is an optional module. It is only available when Python is
configured to include it, which requires that the GNU MP software is
installed.
+\index{MP, GNU library}
+\index{arbitrary precision integers}
+\index{integer!arbitrary precision}
This module implements the interface to part of the GNU MP library,
which defines arbitrary precision integer and rational number
arithmetic routines. Only the interfaces to the \emph{integer}
-(\samp{mpz_{\rm \ldots}}) routines are provided. If not stated
+(\function{mpz_*()}) routines are provided. If not stated
otherwise, the description in the GNU MP documentation can be applied.
In general, \dfn{mpz}-numbers can be used just like other standard
Python numbers, e.g.\ you can use the built-in operators like \code{+},
\code{*}, etc., as well as the standard built-in functions like
-\code{abs}, \code{int}, \ldots, \code{divmod}, \code{pow}.
-\strong{Please note:} the \emph{bitwise-xor} operation has been implemented as
-a bunch of \emph{and}s, \emph{invert}s and \emph{or}s, because the library
-lacks an \code{mpz_xor} function, and I didn't need one.
+\function{abs()}, \function{int()}, \ldots, \function{divmod()},
+\function{pow()}. \strong{Please note:} the \emph{bitwise-xor}
+operation has been implemented as a bunch of \emph{and}s,
+\emph{invert}s and \emph{or}s, because the library lacks an
+\cfunction{mpz_xor()} function, and I didn't need one.
-You create an mpz-number by calling the function called \code{mpz} (see
+You create an mpz-number by calling the function \function{mpz()} (see
below for an exact description). An mpz-number is printed like this:
\code{mpz(\var{value})}.
-\setindexsubitem{(in module mpz)}
+
\begin{funcdesc}{mpz}{value}
Create a new mpz-number. \var{value} can be an integer, a long,
another mpz-number, or even a string. If it is a string, it is
interpreted as an array of radix-256 digits, least significant digit
- first, resulting in a positive number. See also the \code{binary}
+ first, resulting in a positive number. See also the \method{binary()}
method, described below.
\end{funcdesc}
+\begin{datadesc}{MPZType}
+ The type of the objects returned by \function{mpz()} and most other
+ functions in this module.
+\end{datadesc}
+
+
A number of \emph{extra} functions are defined in this module. Non
mpz-arguments are converted to mpz-values first, and the functions
return mpz-numbers.
@@ -40,7 +50,7 @@ return mpz-numbers.
\begin{funcdesc}{powm}{base, exponent, modulus}
Return \code{pow(\var{base}, \var{exponent}) \%{} \var{modulus}}. If
\code{\var{exponent} == 0}, return \code{mpz(1)}. In contrast to the
- \C-library function, this version can handle negative exponents.
+ \C{} library function, this version can handle negative exponents.
\end{funcdesc}
\begin{funcdesc}{gcd}{op1, op2}
@@ -62,18 +72,18 @@ return mpz-numbers.
\end{funcdesc}
\begin{funcdesc}{divm}{numerator, denominator, modulus}
- Returns a number \var{q}. such that
- \code{\var{q} * \var{denominator} \%{} \var{modulus} == \var{numerator}}.
- One could also implement this function in Python, using \code{gcdext}.
+ Returns a number \var{q} such that
+ \code{\var{q} * \var{denominator} \%{} \var{modulus} ==
+ \var{numerator}}. One could also implement this function in Python,
+ using \function{gcdext()}.
\end{funcdesc}
An mpz-number has one method:
-\setindexsubitem{(mpz method)}
-\begin{funcdesc}{binary}{}
+\begin{methoddesc}[mpz]{binary}{}
Convert this mpz-number to a binary string, where the number has been
stored as an array of radix-256 digits, least significant digit first.
The mpz-number must have a value greater than or equal to zero,
- otherwise a \code{ValueError}-exception will be raised.
-\end{funcdesc}
+ otherwise \exception{ValueError} will be raised.
+\end{methoddesc}