1mp(3MP)              Multiple Precision Library Functions              mp(3MP)
2
3
4

NAME

6       mp,  mp_madd,  mp_msub,  mp_mult,  mp_mdiv,  mp_mcmp,  mp_min, mp_mout,
7       mp_pow, mp_gcd, mp_rpow, mp_msqrt, mp_sdiv, mp_itom, mp_xtom,  mp_mtox,
8       mp_mfree - multiple precision integer arithmetic
9

SYNOPSIS

11       cc [ flag... ] file... -lmp [ library... ]
12       #include <mp.h>
13
14       void mp_madd(MINT *a, MINT *b, MINT *c);
15
16
17       void mp_msub(MINT *a, MINT *b, MINT *c);
18
19
20       void mp_mult(MINT *a, MINT *b, MINT *c);
21
22
23       void mp_mdiv(MINT *a, MINT *b, MINT *q, MINT *r);
24
25
26       int mp_mcmp(MINT *a, MINT *b);
27
28
29       int mp_min(MINT *a);
30
31
32       void mp_mout(MINT *a);
33
34
35       void mp_pow(MINT *a, MINT *b, MINT *c, MINT *d);
36
37
38       void mp_gcd(MINT *a, MINT *b, MINT *c);
39
40
41       void mp_rpow(MINT *a, short n, MINT *b);
42
43
44       int mp_msqrt(MINT *a, MINT *b, MINT *r);
45
46
47       void mp_sdiv(MINT *a, short n, MINT *q, short *r);
48
49
50       MINT * mp_itom(short n);
51
52
53       MINT * mp_xtom(char *a);
54
55
56       char * mp_mtox(MINT *a);
57
58
59       void mp_mfree(MINT *a);
60
61

DESCRIPTION

63       These functions perform arithmetic on integers of arbitrary length. The
64       integers are stored using the defined type MINT.  Pointers  to  a  MINT
65       should  be  initialized  using  the function mp_itom(n), which sets the
66       initial value to n. Alternatively, mp_xtom(a) may be used to initialize
67       a  MINT from a string of hexadecimal digits. mp_mfree(a) may be used to
68       release the storage allocated by the  mp_itom(a)  and  mp_xtom(a)  rou‐
69       tines.
70
71
72       The  mp_madd(a,b,c), mp_msub(a,b,c) and mp_mult(a,b,c) functions assign
73       to their third arguments the  sum,  difference,  and  product,  respec‐
74       tively,  of  their  first two arguments.  The mp_mdiv(a,b,q,r) function
75       assigns the quotient and remainder,  respectively,  to  its  third  and
76       fourth   arguments.    The  mp_sdiv(a,n,q,r)  function  is  similar  to
77       mp_mdiv(a,b,q,r) except that the divisor is an ordinary  integer.   The
78       mp_msqrt(a,b,r)  function produces the square root and remainder of its
79       first argument.  The  mp_mcmp(a,b) function compares the values of  its
80       arguments  and  returns  0 if the two values are equal, a value greater
81       than  0 if the first argument is greater than the second, and  a  value
82       less  than   0  if  the second argument is greater than the first.  The
83       mp_rpow(a,n,b) function raises a to the  nth  power  and  assigns  this
84       value  to  b.  The mp_pow(a,b ,c,d) function raises a to the bth power,
85       reduces the result  modulo c and assigns this value to d. The mp_min(a)
86       and   mp_mout(a)  functions  perform  decimal  input  and  output.  The
87       mp_gcd(a,b,c) function finds the greatest common divisor of  the  first
88       two  arguments,  returning  it  in the third argument.  The mp_mtox( a)
89       function provides the inverse of mp_xtom(a).  To  release  the  storage
90       allocated by mp_mtox(a) use free() (see malloc(3C)).
91
92
93       Use the -lmp loader option to obtain access to these functions.
94

FILES

96       /usr/lib/libmp.so    shared object
97
98

ATTRIBUTES

100       See attributes(5) for descriptions of the following attributes:
101
102
103
104
105       ┌─────────────────────────────┬─────────────────────────────┐
106       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
107       ├─────────────────────────────┼─────────────────────────────┤
108       │MT-Level                     │Unsafe                       │
109       └─────────────────────────────┴─────────────────────────────┘
110

SEE ALSO

112       exp(3M), malloc(3C), libmp(3LIB), attributes(5)
113

DIAGNOSTICS

115       Illegal  operations and running out of memory produce messages and core
116       images.
117

WARNINGS

119       The function pow() exists in both libmp and libm with widely  differing
120       semantics.  This  is  the  reason  libmp.so.2 exists. libmp.so.1 exists
121       solely for reasons of backward compatibility, and should  not  be  used
122       otherwise. Use the  mp_*() functions instead.  See libmp(3LIB).
123
124
125
126SunOS 5.11                        14 Nov 2002                          mp(3MP)
Impressum