Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mp(3X) — bsd — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

bc(1)

dc(1)



MP(3X-BSD)          RISC/os Reference Manual           MP(3X-BSD)



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 precision integer arithmetic

SYNOPSIS
     #include <mp.h>
     #include <stdio.h>

     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)
     min(a, n, f)
     mout(a)
     omout(a)
     fmout(a, f)
     mout(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)

     MINT *xtom(s)
     char *s;
     char *mtox(a)
     MINT *a;

     void mfree(a)
     MINT *a;

DESCRIPTION
     These routines perform arithmetic on integers of arbitrary
     length.  The integers are stored using the defined type
     MINT.  Pointers to a MINT can be initialized using the



                        Printed 11/19/92                   Page 1




MP(3X-BSD)          RISC/os Reference Manual           MP(3X-BSD)



     function itom which sets the initial value to n.  Alterna-
     tively, xtom may be used to initialize a MINT from a string
     of hexadecimal digits.  mfree() may be used to release the
     storage allocated by these routines.

     madd, msub and mult assign to c the sum, difference and pro-
     duct, respectively, of a and b.  mdiv assigns to q and r the
     quotient and remainder obtained from dividing a by b.  sdiv
     is like mdiv except that the divisor is a short integer n
     and the remainder is placed in a short whose address is
     given as r.  msqrt produces the integer square root of a in
     b and places the remainder in r.  rpow calculates in c the
     value of a raised to the (``regular'' integral) power n,
     while pow calculates this with a full multiple precision
     exponent b and the result is reduced modulo m.  gcd returns
     the greatest common denominator of a and b in c, and com-
     putes c such that a*c mod b = 1, for a and b relatively
     prime.  mcmp returns a negative, zero or positive integer
     value when a is less than, equal to or greater than b,
     respectively.  move copies a to b.  min and mout do decimal
     input and output while omin and omout do octal input and
     output.  More generally, fmin and fmout do decimal input and
     output using file f, and min and mout do I/O with arbi-
     trary radix n.  On input, records should have the form of
     strings of digits terminated by a newline; output records
     have a similar form.  mtox() provides the inverse of xtom.

     Programs which use the multiple-precision arithmetic library
     must be loaded using the loader flag -lmp.

FILES
     /usr/include/mp.h   include file
     /usr/lib/libmp.a    object code library

SEE ALSO
     bc(1), dc(1) in the User's Reference Manual.

DIAGNOSTICS
     Illegal operations and running out of memory produce mes-
     sages and core images.

ERRORS
     Bases for input and output should be <= 10.

     dc(1) and bc(1) don't use this library.

     The input and output routines are a crock.

     pow is also the name of a standard math library routine.






 Page 2                 Printed 11/19/92



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026