Go to the first, previous, next, last section, table of contents.
These functions are intended to be fully compatible with the Berkeley MP
library which is available on many BSD derived U*ix systems. The
`--enable-mpbsd' option must be used when building GNU MP to make these
available (see section Installing GMP).
The original Berkeley MP library has a usage restriction: you cannot use the
same variable as both source and destination in a single function call. The
compatible functions in GNU MP do not share this restriction--inputs and
outputs may overlap.
It is not recommended that new programs are written using these functions.
Apart from the incomplete set of functions, the interface for initializing
MINT
objects is more error prone, and the pow
function collides
with pow
in `libm.a'.
Include the header `mp.h' to get the definition of the necessary types
and functions. If you are on a BSD derived system, make sure to include GNU
`mp.h' if you are going to link the GNU `libmp.a' to your program.
This means that you probably need to give the -I<dir> option to the compiler,
where <dir> is the directory where you have GNU `mp.h'.
- Function: MINT * itom (signed short int initial_value)
-
Allocate an integer consisting of a
MINT
object and dynamic limb space.
Initialize the integer to initial_value. Return a pointer to the
MINT
object.
- Function: MINT * xtom (char *initial_value)
-
Allocate an integer consisting of a
MINT
object and dynamic limb space.
Initialize the integer from initial_value, a hexadecimal, '\0'-terminate
C string. Return a pointer to the MINT
object.
- Function: void move (MINT *src, MINT *dest)
-
Set dest to src by copying. Both variables must be previously
initialized.
- Function: void madd (MINT *src_1, MINT *src_2, MINT *destination)
-
Add src_1 and src_2 and put the sum in destination.
- Function: void msub (MINT *src_1, MINT *src_2, MINT *destination)
-
Subtract src_2 from src_1 and put the difference in
destination.
- Function: void mult (MINT *src_1, MINT *src_2, MINT *destination)
-
Multiply src_1 and src_2 and put the product in
destination.
- Function: void mdiv (MINT *dividend, MINT *divisor, MINT *quotient, MINT *remainder)
-
- Function: void sdiv (MINT *dividend, signed short int divisor, MINT *quotient, signed short int *remainder)
-
Set quotient to dividend/divisor, and remainder to
dividend mod divisor. The quotient is rounded towards zero; the
remainder has the same sign as the dividend unless it is zero.
Some implementations of these functions work differently--or not at all--for
negative arguments.
- Function: void msqrt (MINT *operand, MINT *root, MINT *remainder)
-
@ifnottex
Set root to the truncated integer part of the square root of
operand. Set remainder to
operand-root*root,
(i.e., zero if operand is a perfect square).
If root and remainder are the same variable, the results are
undefined.
- Function: void pow (MINT *base, MINT *exp, MINT *mod, MINT *dest)
-
Set dest to (base raised to exp) modulo mod.
- Function: void rpow (MINT *base, signed short int exp, MINT *dest)
-
Set dest to base raised to exp.
- Function: void gcd (MINT *operand1, MINT *operand2, MINT *res)
-
Set res to the greatest common divisor of operand1 and
operand2.
- Function: int mcmp (MINT *operand1, MINT *operand2)
-
Compare operand1 and operand2. Return a positive value if
operand1 > operand2, zero if operand1 =
operand2, and a negative value if operand1 < operand2.
- Function: void min (MINT *dest)
-
Input a decimal string from
stdin
, and put the read integer in
dest. SPC and TAB are allowed in the number string, and are ignored.
- Function: void mout (MINT *src)
-
Output src to
stdout
, as a decimal string. Also output a newline.
- Function: char * mtox (MINT *operand)
-
Convert operand to a hexadecimal string, and return a pointer to the
string. The returned string is allocated using the default memory allocation
function,
malloc
by default.
- Function: void mfree (MINT *operand)
-
De-allocate, the space used by operand. This function should
only be passed a value returned by
itom
or xtom
.
Go to the first, previous, next, last section, table of contents.