Manual Page Result
0
Command: mp | Section: 3 | Source: UNIX v10 | File: mp.3
MP(3X) MP(3X)
NAME
itom, mfree, madd, msub, mult, mdiv, sdiv, msqrt, mgcd, min, mout,
fmin, fmout, move, mcmp, rpow, mpow - multiple precision integer arith-
metic
SYNOPSIS
#include <mp.h>
#include <stdio.h>
mint *itom(n)
short n;
mfree(a)
mint *a;
madd(a, b, c)
mint *a, *b, *c;
msub(a, b, c)
mint *a, *b, *c;
mult(a, b, c)
mint *a, *b, *c;
mgcd(a, b, c)
mint *a, *b, *c;
mdiv(a, b, q, r)
mint *a, *b, *q, *r;
sdiv(a, n, q, r)
mint *a, *q;
short n, *r;
msqrt(a, b, r)
mint *a, *b, *r;
rpow(a, n, c)
mint *a, *c;
mpow(a, b, m, c)
mint *a, *b, *m, *c;
move(a, b)
mint *a, *b;
mcmp(a, b)
mint *a, *b;
int min(a)
mint *a;
mout(a)
mint *a;
int fmin(a, f)
mint *a;
FILE *f;
fmout(a, f)
mint *a;
FILE *f;
DESCRIPTION
These routines perform arithmetic on arbitrary-length integers of de-
fined type mint. The functions are obtained with the 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 automati-
cally. The space may be freed by mfree, making the variable uninitial-
ized.
Madd, msub, mult, 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. The remainder is nonnegative and less than the divi-
sor in magnitude. Sdiv is like mdiv except that the divisor is an or-
dinary integer.
Msqrt assigns the square root and remainder to its second and third ar-
guments, respectively.
Rpow calculates a raised to the power n; mpow calculates this reduced
modulo m.
Move assigns (by copying) 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.
Min and mout do decimal conversion from stdin and to stdout, fmin and
fmout use file f; see stdio(3). Min and fmin return EOF on end of
file.
DIAGNOSTICS
Illegal operations and running out of memory produce messages and core
images.
BUGS
Itom and sdiv fail if n is the most negative short integer.
MP(3X)