Go to the previous, next section.
GNU MP is a portable library for arbitrary precision integer and rational number arithmetic.(1) It aims to provide the fastest possible arithmetic for all applications that need more than two words of integer precision.
Most often, applications tend to use just a few words of precision; but some applications may need thousands of words. GNU MP is designed to give good performance for both kinds of applications, by choosing algorithms based on the sizes of the operands.
There are five groups of functions in the MP library:
mpz_
.
mpq_
.
itom
, madd
,
and mult
.
mpn_
.
As a general rule, all MP functions expect output arguments before input arguments. This notation is based on an analogy with the assignment operator. (The BSD MP compatibility functions disobey this rule, having the output argument(s) last.) Multi-precision numbers, whether output or input, are always passed as addresses to the declared type.
In this manual, integer means a multiple precision integer, as
used in the MP package. The C data type for such integers is
MP_INT
. For example:
MP_INT sum; struct foo { MP_INT x, y; }; MP_INT vec[20];
Rational number means a multiple precision fraction. The C data
type for these fractions is MP_RAT
. For example:
MP_RAT quotient;
A limb means the part of a multi-precision number that fits in a single word. (We chose this word because a limb of the human body is analogous to a digit, only larger, and containing several digits.) Normally a limb contains 32 bits.
I would like to thank Gunnar Sjoedin and Hans Riesel for their help with mathematical problems, Richard Stallman for his help with design issues and for revising this manual, Brian Beuning and Doug Lea for their testing of various versions of the library, and Joachim Hollman for his many valuable suggestions.
Special thanks to Brian Beuning, he has shaked out many bugs from early versions of the code!
John Amanatides of York University in Canada contributed the function
mpz_probab_prime_p
.
Go to the previous, next section.