'\" te
.\"  Copyright (c) 2002 Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH MP 3MP "Nov 14, 2002"
.SH NAME
mp, mp_madd, mp_msub, mp_mult, mp_mdiv, mp_mcmp, mp_min, mp_mout, mp_pow,
mp_gcd, mp_rpow, mp_msqrt, mp_sdiv, mp_itom, mp_xtom, mp_mtox, mp_mfree \-
multiple precision integer arithmetic
.SH SYNOPSIS
.LP
.nf
\fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-lmp\fR [ \fIlibrary\fR... ]
#include <mp.h>

\fBvoid\fR \fBmp_madd\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR);
.fi

.LP
.nf
\fBvoid\fR \fBmp_msub\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR);
.fi

.LP
.nf
\fBvoid\fR \fBmp_mult\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR);
.fi

.LP
.nf
\fBvoid\fR \fBmp_mdiv\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIq\fR, \fBMINT *\fR\fIr\fR);
.fi

.LP
.nf
\fBint\fR \fBmp_mcmp\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR);
.fi

.LP
.nf
\fBint\fR \fBmp_min\fR(\fBMINT *\fR\fIa\fR);
.fi

.LP
.nf
\fBvoid\fR \fBmp_mout\fR(\fBMINT *\fR\fIa\fR);
.fi

.LP
.nf
\fBvoid\fR \fBmp_pow\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR, \fBMINT *\fR\fId\fR);
.fi

.LP
.nf
\fBvoid\fR \fBmp_gcd\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR);
.fi

.LP
.nf
\fBvoid\fR \fBmp_rpow\fR(\fBMINT *\fR\fIa\fR, \fBshort\fR \fIn\fR, \fBMINT *\fR\fIb\fR);
.fi

.LP
.nf
\fBint\fR \fBmp_msqrt\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIr\fR);
.fi

.LP
.nf
\fBvoid\fR \fBmp_sdiv\fR(\fBMINT *\fR\fIa\fR, \fBshort\fR \fIn\fR, \fBMINT *\fR\fIq\fR, \fBshort *\fR\fIr\fR);
.fi

.LP
.nf
\fBMINT *\fR \fBmp_itom\fR(\fBshort\fR \fIn\fR);
.fi

.LP
.nf
\fBMINT *\fR \fBmp_xtom\fR(\fBchar *\fR\fIa\fR);
.fi

.LP
.nf
\fBchar *\fR \fBmp_mtox\fR(\fBMINT *\fR\fIa\fR);
.fi

.LP
.nf
\fBvoid\fR \fBmp_mfree\fR(\fBMINT *\fR\fIa\fR);
.fi

.SH DESCRIPTION
.sp
.LP
These functions perform arithmetic on integers of arbitrary length. The
integers are stored using the defined type \fBMINT\fR. Pointers to a \fBMINT\fR
should be initialized using the function \fBmp_itom(\fIn\fR)\fR, which sets the
initial value to \fIn\fR. Alternatively, \fBmp_xtom(\fIa\fR)\fR may be used to
initialize a \fBMINT\fR from a string of hexadecimal digits.
\fBmp_mfree(\fIa\fR)\fR may be used to release the storage allocated by the
\fBmp_itom(\fIa\fR)\fR and \fBmp_xtom(\fIa\fR)\fR routines.
.sp
.LP
The \fBmp_madd\fR(\fIa\fR,\fIb\fR,\fIc\fR),
\fBmp_msub\fR(\fIa\fR,\fIb\fR,\fIc\fR) and
\fBmp_mult\fR(\fIa\fR,\fIb\fR,\fIc\fR) functions assign to their third
arguments the sum, difference, and product, respectively, of their first two
arguments.  The \fBmp_mdiv\fR(\fIa\fR,\fIb\fR,\fIq\fR,\fIr\fR) function assigns
the quotient and remainder, respectively, to its third and fourth arguments.
The \fBmp_sdiv\fR(\fIa\fR,\fIn\fR,\fIq\fR,\fIr\fR) function is similar to
\fBmp_mdiv\fR(\fIa\fR,\fIb\fR,\fIq\fR,\fIr\fR) except that the divisor is an
ordinary integer.  The \fBmp_msqrt\fR(\fIa\fR,\fIb\fR,\fIr\fR) function
produces the square root and remainder of its first argument.  The \fB
mp_mcmp\fR(\fIa\fR,\fIb\fR) function compares the values of its arguments and
returns  \fB0\fR if the two values are equal, a value greater than  \fB0\fR if
the first argument is greater than the second, and a value less than  \fB0\fR
if the second argument is greater than the first.  The
\fBmp_rpow\fR(\fIa\fR,\fIn\fR,\fIb\fR) function raises \fIa\fR to the \fIn\fRth
power and assigns this value to \fIb\fR. The \fBmp_pow\fR(\fIa\fR,\fIb\fR
,\fIc\fR,\fId\fR) function raises \fIa\fR to the \fIb\fRth power, reduces the
result  \fBmodulo\fR \fIc\fR and assigns this value to \fId\fR. The
\fBmp_min(\fIa\fR)\fR and \fBmp_mout(\fIa\fR)\fR functions perform decimal
input and output. The \fBmp_gcd\fR(\fIa\fR,\fIb\fR,\fIc\fR) function finds the
greatest common divisor of the first two arguments, returning it in the third
argument.  The \fBmp_mtox(\fI a\fR)\fR function provides the inverse of
\fBmp_xtom(a)\fR. To release the storage allocated by \fBmp_mtox(\fIa\fR)\fR
use \fBfree()\fR (see \fBmalloc\fR(3C)).
.sp
.LP
Use the \fB-lmp\fR loader option to obtain access to these functions.
.SH FILES
.sp
.ne 2
.na
\fB\fB/usr/lib/libmp.so\fR\fR
.ad
.RS 21n
shared object
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
MT-Level	Unsafe
.TE

.SH SEE ALSO
.sp
.LP
\fBexp\fR(3M), \fBmalloc\fR(3C), \fBlibmp\fR(3LIB), \fBattributes\fR(5)
.SH DIAGNOSTICS
.sp
.LP
Illegal operations and running out of memory produce messages and core images.
.SH WARNINGS
.sp
.LP
The function \fBpow()\fR exists in both \fBlibmp\fR and \fBlibm\fR with widely
differing semantics. This is the reason \fBlibmp.so.2\fR exists.
\fBlibmp.so.1\fR exists solely for reasons of backward compatibility, and
should not be used otherwise. Use the  \fBmp_*(\|)\fR functions instead.  See
\fBlibmp\fR(3LIB).