term% cat index.txt MP(3X) MP(3X)
NAME
itom, madd, msub, mmul, mdiv, msqrt, mgcd, mget, mput, mmov, mcmp,
mexp, mpow - multiple precision integer arithmetic
SYNOPSIS
#include <mp.h>
mint *itom(n)
int n;
madd(a, b, c)
msub(a, b, c)
mmul(a, b, c)
mgcd(a, b, c)
mdiv(a, b, q, r)
msqrt(a, b, r)
mexp(a, b, c)
mpow(a, b, m, c)
mmov(a, b)
mcmp(a, b)
mget(a)
mput(a)
mint *a, *b, *c, *m, *q, *r;
sdiv(a, n, q, r)
mint *a, *q;
int n;
short *r;
DESCRIPTION
These routines perform arithmetic on arbitrary-length integers of de‐
fined type mint. The functions are obtained with ld(1) option -lmp.
Pointers to mint must be initialized using the function itom, which
sets the initial value to n. Thereafter space is managed automatically
by the routines.
Madd, msub, mmul, and mgcd assign to their third arguments the sum,
difference, product, and greatest common divisor, respectively, of
their first two arguments.
Mdiv assigns the quotient and remainder, respectively, to its third and
fourth arguments. Sdiv is like mdiv except that the divisor is an or‐
dinary integer.
Msqrt assigns to its second and third arguments the square root and re‐
mainder, repsectively, of its first argument.
Mexp calculates a raised to the power b; mpow calculates this reduced
modulo m.
Mmov assigns the value of its first argument to its second argument.
Mcmp returns a negative, zero, or positive integer if the value of its
first argument is less than, equal to, or greater than, respectively,
the value of its second argument.
Mget and mput do decimal conversion from ‘stdin' and to ‘stdout', re‐
spectively, of stdio(3).
DIAGNOSTICS
Illegal operations and running out of memory produce messages and core
images.
MP(3X)