MP(3X) MP(3X) NAME madd, msub, mult, mdiv, pow, gcd, invert, rpow, msqrt, mcmp, move, min, omin, fmin, m_in, mout, omout, fmout, m_out, sdiv, itom - multiple pre‐ cision integer arithmetic SYNOPSIS #include #include typedef struct mint { int len; short *val; } MINT; madd(a, b, c) msub(a, b, c) mult(a, b, c) mdiv(a, b, q, r) pow(a, b, m, c) gcd(a, b, c) invert(a, b, c) rpow(a, n, c) msqrt(a, b, r) mcmp(a, b) move(a, b) min(a) omin(a) fmin(a, f) m_in(a, n, f) mout(a) omout(a) fmout(a, f) m_out(a, n, f) MINT *a, *b, *c, *m, *q, *r; FILE *f; int n; sdiv(a, n, q, r) MINT *a, *q; short n; short *r; MINT *itom(n) DESCRIPTION These routines perform arithmetic on integers of arbitrary length. The integers are stored using the defined type _M_I_N_T. Pointers to a _M_I_N_T can be initialized using the function _i_t_o_m which sets the initial value to _n. After that, space is managed automatically by the routines. _m_a_d_d, _m_s_u_b and _m_u_l_t assign to _c the sum, difference and product, respectively, of _a and _b. _m_d_i_v assigns to _q and _r the quotient and remainder obtained from dividing _a by _b_. _s_d_i_v is like _m_d_i_v except that the divisor is a short integer _n and the remainder is placed in a short whose address is given as _r. _m_s_q_r_t produces the integer square root of _a in _b and places the remainder in _r. _r_p_o_w calculates in _c the value of _a raised to the (‘‘regular’’ integral) power _n, while _p_o_w calculates this with a full multiple precision exponent _b and the result is reduced modulo _m. _g_c_d returns the greatest common denominator of _a and _b in _c, and _i_n_v_e_r_t computes _c such that _a_*_c mod _b = 1, for _a and _b rel‐ atively prime. _m_c_m_p returns a negative, zero or positive integer value when _a is less than, equal to or greater than _b, respectively. _m_o_v_e copies _a to _b. _m_i_n and _m_o_u_t do decimal input and output while _o_m_i_n and _o_m_o_u_t do octal input and output. More generally, _f_m_i_n and _f_m_o_u_t do decimal input and output using file _f, and _m__i_n and _m__o_u_t do I/O with arbitrary radix _n. On input, records should have the form of strings of digits terminated by a newline; output records have a similar form. Programs which use the multiple-precision arithmetic library must be loaded using the loader flag _-_l_m_p. FILES /usr/include/mp.h include file /usr/lib/libmp.a object code library SEE ALSO dc(1), bc(1) DIAGNOSTICS Illegal operations and running out of memory produce messages and core images. BUGS Bases for input and output should be <= 10. _d_c(1) and _b_c(1) don’t use this library. The input and output routines are a crock. _p_o_w is also the name of a standard math library routine. 4.3 Berkeley Distribution June 4, 1986 MP(3X)