man(1) Manual page archive


     MP(3X)                                                     MP(3X)

     NAME
          itom, mfree, madd, msub, mult, mdiv, sdiv, msqrt, mgcd, min,
          mout, fmin, fmout, move, mcmp, rpow, mpow - multiple
          precision integer arithmetic

     SYNOPSIS
          #include <mp.h>
          #include <stdio.h>        msqrt(a, b, r)
                                          mint *a, *b, *r;
          mint *itom(n)
          short n;                        rpow(a, n, c)
                                          mint *a, *c;
          mfree(a)
          mint *a;                        mpow(a, b, m, c)
                                          mint *a, *b, *m, *c;
          madd(a, b, c)
          mint *a, *b, *c;                move(a, b)
                                          mint *a, *b;
          msub(a, b, c)
          mint *a, *b, *c;                mcmp(a, b)
                                          mint *a, *b;
          mult(a, b, c)
          mint *a, *b, *c;                int min(a)
                                          mint *a;
          mgcd(a, b, c)
          mint *a, *b, *c;                mout(a)
                                          mint *a;
          mdiv(a, b, q, r)
          mint *a, *b, *q, *r;            int fmin(a, f)
                                          mint *a;
          sdiv(a, n, q, r)                FILE *f;
          mint *a, *q;
          short n, *r;                    fmout(a, f)
                                          mint *a;
                                          FILE *f;

    DESCRIPTION
         These routines perform arithmetic on arbitrary-length inte-
         gers of defined type mint. The functions are obtained with
         the ld(1) option -lmp.

         Pointers to mint must be initialized using the function
         itom, which sets the initial value to n. Thereafter space is
         managed automatically.  The space may be freed by mfree,
         making the variable uninitialized.

         Madd, msub, mult, and mgcd assign to their third arguments
         the sum, difference, product, and greatest common divisor,
         respectively, of their first two arguments.

    MP(3X)                                                     MP(3X)

         Mdiv assigns the quotient and remainder, respectively, to
         its third and fourth arguments.  The remainder is nonnega-
         tive and less than the divisor in magnitude.  Sdiv is like
         mdiv except that the divisor is an ordinary integer.

         Msqrt assigns the square root and remainder to its second
         and third arguments, respectively.

         Rpow calculates a raised to the power n; mpow calculates
         this reduced modulo m.

         Move assigns (by copying) the value of its first argument to
         its second argument.

         Mcmp returns a negative, zero, or positive integer if the
         value of its first argument is less than, equal to, or
         greater than, respectively, the value of its second argu-
         ment.

         Min and mout do decimal conversion from stdin and to stdout,
         fmin and fmout use file f; see stdio(3). Min and fmin return
         EOF on end of file.

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

    BUGS
         Itom and sdiv fail if n is the most negative short integer.