|
|
1.1 root 1: .\" Copyright (c) 1986 Regents of the University of California.
2: .\" All rights reserved. The Berkeley software License Agreement
3: .\" specifies the terms and conditions for redistribution.
4: .\"
5: .\" @(#)mp.3x 6.4 (Berkeley) 6/4/86
6: .\"
7: .TH MP 3X "June 4, 1986"
8: .UC 6
9: .SH NAME
10: madd, msub, mult, mdiv, pow, gcd, invert, rpow, msqrt, mcmp,
11: move, min, omin, fmin, m_in, mout, omout, fmout, m_out, sdiv, itom
12: \- multiple precision integer arithmetic
13: .SH SYNOPSIS
14: .nf
15: .B #include <mp.h>
16: .B #include <stdio.h>
17: .PP
18: .B "typedef struct mint { int len; short *val; } MINT;"
19: .PP
20: .B madd(a, b, c)
21: .B msub(a, b, c)
22: .B mult(a, b, c)
23: .B mdiv(a, b, q, r)
24: .B pow(a, b, m, c)
25: .B gcd(a, b, c)
26: .B invert(a, b, c)
27: .B rpow(a, n, c)
28: .B msqrt(a, b, r)
29: .B mcmp(a, b)
30: .B move(a, b)
31: .B min(a)
32: .B omin(a)
33: .B fmin(a, f)
34: .B m_in(a, n, f)
35: .B mout(a)
36: .B omout(a)
37: .B fmout(a, f)
38: .B m_out(a, n, f)
39: .B MINT *a, *b, *c, *m, "*q, *r;"
40: .B FILE *f;
41: .B int n;
42: .PP
43: .B sdiv(a, n, q, r)
44: .B MINT *a, *q;
45: .B short n;
46: .B short *r;
47: .PP
48: .B MINT *itom(n)
49: .SH DESCRIPTION
50: These routines perform arithmetic on integers of
51: arbitrary length.
52: The integers are stored using the defined type
53: .IR MINT .
54: Pointers to a
55: .I MINT
56: can be initialized using the function
57: .I itom
58: which sets the initial value to
59: .IR n .
60: After that, space is managed automatically by the routines.
61: .PP
62: .IR madd , " msub " and " mult"
63: assign to
64: .I c
65: the sum, difference and
66: product, respectively, of
67: .IR a " and " b .
68: .I mdiv
69: assigns to
70: .IR q " and " r
71: the quotient and remainder obtained
72: from dividing
73: .IR a " by " b.
74: .I sdiv
75: is like
76: .I mdiv
77: except that the divisor is a short integer
78: .I n
79: and the remainder is placed in a short
80: whose address is given as
81: .IR r .
82: .I msqrt
83: produces the integer square root of
84: .IR a " in " b
85: and places the remainder in
86: .IR r .
87: .I rpow
88: calculates in
89: .I c
90: the value of
91: .I a
92: raised to the (``regular'' integral) power
93: .IR n ,
94: while
95: .I pow
96: calculates this with a full multiple precision exponent
97: .I b
98: and the result is reduced modulo
99: .IR m .
100: .I gcd
101: returns the greatest common denominator of
102: .IR a " and " b " in " c ,
103: and
104: .I invert
105: computes
106: .IR c " such that " a*c " mod " b " = 1,"
107: for
108: .IR a " and " b
109: relatively prime.
110: .I mcmp
111: returns a negative, zero or positive integer value when
112: .I a
113: is less than, equal to or greater than
114: .IR b ,
115: respectively.
116: .I move
117: copies
118: .IR a " to " b .
119: .IR min " and " mout
120: do decimal input and output while
121: .IR omin " and " omout
122: do octal input and output.
123: More generally,
124: .IR fmin " and " fmout
125: do decimal input and output using file
126: .IR f ,
127: and
128: .IR m_in " and " m_out
129: do I/O with arbitrary radix
130: .IR n .
131: On input, records should have the form of
132: strings of digits terminated by a newline;
133: output records have a similar form.
134: .PP
135: Programs which use the multiple-precision arithmetic library
136: must be loaded using the loader flag
137: .IR \-lmp .
138: .SH FILES
139: .ta 2i
140: /usr/include/mp.h include file
141: .br
142: /usr/lib/libmp.a object code library
143: .SH SEE ALSO
144: dc(1), bc(1)
145: .SH DIAGNOSTICS
146: Illegal operations and running out of memory
147: produce messages and core images.
148: .SH BUGS
149: Bases for input and output should be <= 10.
150: .PP
151: .IR dc (1)
152: and
153: .IR bc (1)
154: don't use this library.
155: .PP
156: The input and output routines are a crock.
157: .PP
158: .I pow
159: is also the name of a standard math library routine.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.