2 .\" Copyright (c) 2002 Sun Microsystems, Inc. All Rights Reserved.
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH MP 3MP "Nov 14, 2002"
8 mp, mp_madd, mp_msub, mp_mult, mp_mdiv, mp_mcmp, mp_min, mp_mout, mp_pow,
9 mp_gcd, mp_rpow, mp_msqrt, mp_sdiv, mp_itom, mp_xtom, mp_mtox, mp_mfree \-
10 multiple precision integer arithmetic
14 \fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-lmp\fR [ \fIlibrary\fR... ]
17 \fBvoid\fR \fBmp_madd\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR);
22 \fBvoid\fR \fBmp_msub\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR);
27 \fBvoid\fR \fBmp_mult\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR);
32 \fBvoid\fR \fBmp_mdiv\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIq\fR, \fBMINT *\fR\fIr\fR);
37 \fBint\fR \fBmp_mcmp\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR);
42 \fBint\fR \fBmp_min\fR(\fBMINT *\fR\fIa\fR);
47 \fBvoid\fR \fBmp_mout\fR(\fBMINT *\fR\fIa\fR);
52 \fBvoid\fR \fBmp_pow\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR, \fBMINT *\fR\fId\fR);
57 \fBvoid\fR \fBmp_gcd\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIc\fR);
62 \fBvoid\fR \fBmp_rpow\fR(\fBMINT *\fR\fIa\fR, \fBshort\fR \fIn\fR, \fBMINT *\fR\fIb\fR);
67 \fBint\fR \fBmp_msqrt\fR(\fBMINT *\fR\fIa\fR, \fBMINT *\fR\fIb\fR, \fBMINT *\fR\fIr\fR);
72 \fBvoid\fR \fBmp_sdiv\fR(\fBMINT *\fR\fIa\fR, \fBshort\fR \fIn\fR, \fBMINT *\fR\fIq\fR, \fBshort *\fR\fIr\fR);
77 \fBMINT *\fR \fBmp_itom\fR(\fBshort\fR \fIn\fR);
82 \fBMINT *\fR \fBmp_xtom\fR(\fBchar *\fR\fIa\fR);
87 \fBchar *\fR \fBmp_mtox\fR(\fBMINT *\fR\fIa\fR);
92 \fBvoid\fR \fBmp_mfree\fR(\fBMINT *\fR\fIa\fR);
98 These functions perform arithmetic on integers of arbitrary length. The
99 integers are stored using the defined type \fBMINT\fR. Pointers to a \fBMINT\fR
100 should be initialized using the function \fBmp_itom(\fIn\fR)\fR, which sets the
101 initial value to \fIn\fR. Alternatively, \fBmp_xtom(\fIa\fR)\fR may be used to
102 initialize a \fBMINT\fR from a string of hexadecimal digits.
103 \fBmp_mfree(\fIa\fR)\fR may be used to release the storage allocated by the
104 \fBmp_itom(\fIa\fR)\fR and \fBmp_xtom(\fIa\fR)\fR routines.
107 The \fBmp_madd\fR(\fIa\fR,\fIb\fR,\fIc\fR),
108 \fBmp_msub\fR(\fIa\fR,\fIb\fR,\fIc\fR) and
109 \fBmp_mult\fR(\fIa\fR,\fIb\fR,\fIc\fR) functions assign to their third
110 arguments the sum, difference, and product, respectively, of their first two
111 arguments. The \fBmp_mdiv\fR(\fIa\fR,\fIb\fR,\fIq\fR,\fIr\fR) function assigns
112 the quotient and remainder, respectively, to its third and fourth arguments.
113 The \fBmp_sdiv\fR(\fIa\fR,\fIn\fR,\fIq\fR,\fIr\fR) function is similar to
114 \fBmp_mdiv\fR(\fIa\fR,\fIb\fR,\fIq\fR,\fIr\fR) except that the divisor is an
115 ordinary integer. The \fBmp_msqrt\fR(\fIa\fR,\fIb\fR,\fIr\fR) function
116 produces the square root and remainder of its first argument. The \fB
117 mp_mcmp\fR(\fIa\fR,\fIb\fR) function compares the values of its arguments and
118 returns \fB0\fR if the two values are equal, a value greater than \fB0\fR if
119 the first argument is greater than the second, and a value less than \fB0\fR
120 if the second argument is greater than the first. The
121 \fBmp_rpow\fR(\fIa\fR,\fIn\fR,\fIb\fR) function raises \fIa\fR to the \fIn\fRth
122 power and assigns this value to \fIb\fR. The \fBmp_pow\fR(\fIa\fR,\fIb\fR
123 ,\fIc\fR,\fId\fR) function raises \fIa\fR to the \fIb\fRth power, reduces the
124 result \fBmodulo\fR \fIc\fR and assigns this value to \fId\fR. The
125 \fBmp_min(\fIa\fR)\fR and \fBmp_mout(\fIa\fR)\fR functions perform decimal
126 input and output. The \fBmp_gcd\fR(\fIa\fR,\fIb\fR,\fIc\fR) function finds the
127 greatest common divisor of the first two arguments, returning it in the third
128 argument. The \fBmp_mtox(\fI a\fR)\fR function provides the inverse of
129 \fBmp_xtom(a)\fR. To release the storage allocated by \fBmp_mtox(\fIa\fR)\fR
130 use \fBfree()\fR (see \fBmalloc\fR(3C)).
133 Use the \fB-lmp\fR loader option to obtain access to these functions.
138 \fB\fB/usr/lib/libmp.so\fR\fR
147 See \fBattributes\fR(5) for descriptions of the following attributes:
155 ATTRIBUTE TYPE ATTRIBUTE VALUE
163 \fBexp\fR(3M), \fBmalloc\fR(3C), \fBlibmp\fR(3LIB), \fBattributes\fR(5)
167 Illegal operations and running out of memory produce messages and core images.
171 The function \fBpow()\fR exists in both \fBlibmp\fR and \fBlibm\fR with widely
172 differing semantics. This is the reason \fBlibmp.so.2\fR exists.
173 \fBlibmp.so.1\fR exists solely for reasons of backward compatibility, and
174 should not be used otherwise. Use the \fBmp_*(\|)\fR functions instead. See