Commit | Line | Data |
---|---|---|
7c5a8800 PW |
1 | .TH MP 3X |
2 | .SH NAME | |
3 | itom, madd, msub, mult, mdiv, min, mout, | |
4 | pow, gcd, rpow \- multiple precision integer arithmetic | |
5 | .SH SYNOPSIS | |
6 | .nf | |
7 | .B "typedef struct { int len; short *val; } mint;" | |
8 | .PP | |
9 | .PP | |
10 | .B madd(a, b, c) | |
11 | .B msub(a, b, c) | |
12 | .B mult(a, b, c) | |
13 | .B mdiv(a, b, q, r) | |
14 | .B min(a) | |
15 | .B mout(a) | |
16 | .B pow(a, b, m, c) | |
17 | .B gcd(a, b, c) | |
18 | .B rpow(a, b, c) | |
19 | .B msqrt(a, b, r) | |
20 | .B mint *a, *b, *c, *m, "*q, *r;" | |
21 | .PP | |
22 | .B | |
23 | .B sdiv(a, n, q, r) | |
24 | .B mint *a, *q; | |
25 | .B short *r; | |
26 | .PP | |
27 | .B mint *itom(n) | |
28 | .SH DESCRIPTION | |
29 | These routines perform arithmetic on integers of | |
30 | arbitrary length. | |
31 | The integers are stored using the defined type | |
32 | .I mint. | |
33 | Pointers to | |
34 | a | |
35 | .I mint | |
36 | should be initialized using the function | |
37 | .IR itom , | |
38 | which sets the initial value to | |
39 | .IR n . | |
40 | After that space is managed automatically by the routines. | |
41 | .PP | |
42 | .IR madd , " msub" , " mult" , | |
43 | assign to their third arguments the sum, difference, and | |
44 | product, respectively, of their first two arguments. | |
45 | .I mdiv | |
46 | assigns the quotient and remainder, respectively, | |
47 | to its third and fourth arguments. | |
48 | .I sdiv | |
49 | is like | |
50 | .I mdiv | |
51 | except that the divisor is an ordinary integer. | |
52 | .I msqrt | |
53 | produces the square root and remainder of its first argument. | |
54 | .I rpow | |
55 | calculates | |
56 | .I a | |
57 | raised to the power | |
58 | .IR b , | |
59 | while | |
60 | .I pow | |
61 | calculates this reduced modulo | |
62 | .IR m . | |
63 | .IR min " and" mout | |
64 | do decimal input and output. | |
65 | .PP | |
66 | The functions are obtained with the | |
67 | loader option | |
68 | .IR -lmp . | |
69 | .SH DIAGNOSTICS | |
70 | Illegal operations and running out of memory | |
71 | produce messages and core images. |