Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mp(3X) — Amiga System V Release 4 Version 2.03

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

malloc(3)



mp(3X)           MISCELLANEOUS LIBRARY FUNCTIONS           mp(3X)



NAME
     mp:  madd, msub, mult, mdiv,  mcmp,  min,  mout,  pow,  gcd,
     rpow, msqrt, sdiv, itom, xtom, mtox, mfree - multiple preci-
     sion integer arithmetic

SYNOPSIS
     cc [ flag... ] file ...  -lmp
     #include <mp.h>

     madd(a, b, c)
     MINT *a, *b, *c;
     msub(a, b, c)
     MINT *a, *b, *c;

     mult(a, b, c)
     MINT *a, *b, *c;
     mdiv(a, b, q, r)
     MINT *a, *b, *q, *r;

     mcmp(a,b)
     MINT *a, *b;
     min(a)
     MINT *a;

     mout(a)
     MINT *a;
     pow(a, b, c, d)
     MINT *a, *b, *c, *d;

     gcd(a, b, c)
     MINT *a, *b, *c;
     rpow(a, n, b)
     MINT *a, *b;
     short n;

     msqrt(a, b, r)
     MINT *a, *b, *r;
     sdiv(a, n, q, r)
     MINT *a, *q;
     short n, *r;

     MINT *itom(n)
     short n;
     MINT *xtom(s)
     char *s;

     char *mtox(a)
     MINT *a;
     void mfree(a)
     MINT *a;





             Last change: BSD Compatibility Package             1





mp(3X)           MISCELLANEOUS LIBRARY FUNCTIONS           mp(3X)



DESCRIPTION
     These routines perform arithmetic on integers  of  arbitrary
     length.   The  integers  are  stored  using the defined type
     MINT.  Pointers to a MINT should be  initialized  using  the
     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 the itom and xtom routines.  madd, msub
     and  mult  assign  to their third arguments the sum, differ-
     ence, and product, respectively, of their  first  two  argu-
     ments.   mdiv  assigns  the  quotient and remainder, respec-
     tively, to its third and fourth  arguments.   sdiv  is  like
     mdiv  except that the divisor is an ordinary integer.  msqrt
     produces the square root and remainder of  its  first  argu-
     ment.  mcmp compares the values of its arguments and returns
     0 if the two values are equal, >0 if the first  argument  is
     greater  than  the  second, and <0 if the second argument is
     greater than the first.  rpow calculates  a  raised  to  the
     power  b,  while  pow calculates this reduced modulo m.  min
     and mout  do  decimal  input  and  output.   gcd  finds  the
     greatest  common divisor of the first two arguments, return-
     ing it in the third argument.  mtox provides the inverse  of
     xtom.   To  release  the storage allocated by mtox, use free
     [see malloc(3)].  Use the -libmp  loader  option  to  obtain
     access to these functions.

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

FILES
     /usr/ucblib/libmp.a

SEE ALSO
     malloc(3) in the Programmer's Reference Manual.




















             Last change: BSD Compatibility Package             2



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