IPnom Home • Manuals • FreeBSD

 FreeBSD Man Pages

Man Sections:Commands (1)System Calls (2)Library Functions (3)Device Drivers (4)File Formats (5)Miscellaneous (7)System Utilities (8)
Keyword Live Search (10 results max):
 Type in part of a command in the search box.
 


libmp(3)

NAME

     libmp -- traditional BSD multiple precision integer arithmetic library


SYNOPSIS

     #include <mp.h>

     Function prototypes are given in the main body of the text.

     Applications using this interface must be linked with -lmp (this library)
     and -lcrypto (crypto(3)).


DESCRIPTION

     This interface is obsolete in favor of the crypto(3) BIGNUM library.

     libmp is the traditional BSD multiple precision integer arithmetic
     library.  It has a number of problems, and is unsuitable for use in any
     programs where reliability is a concern.  It is provided here for compat-
     ibility only.

     These routines perform arithmetic on integers of arbitrary precision
     stored using the defined type MINT.  Pointers to MINT are initialized
     using itom() or xtom(), and must be recycled with mfree() when they are
     no longer needed.	Routines which store a result in one of their argu-
     ments expect that the latter has also been initialized prior to being
     passed to it.  The following routines are defined and implemented:

     MINT *itom(short n);

     MINT *xtom(const char *s);

     char *mtox(const MINT *mp);

     void mfree(MINT *mp);

	   itom() returns an MINT with the value of n.	xtom() returns an MINT
	   with the value of s, which is treated to be in hexadecimal.	The
	   return values from itom() and xtom() must be released with mfree()
	   when they are no longer needed.  mtox() returns a null-terminated
	   hexadecimal string having the value of mp; its return value must be
	   released with free() (free(3)) when it is no longer needed.

     void madd(const MINT *mp1, const MINT *mp2, MINT *rmp);

     void msub(const MINT *mp1, const MINT *mp2, MINT *rmp);

     void mult(const MINT *mp1, const MINT *mp2, MINT *rmp);

	   madd(), msub(), and mult() store the sum, difference, or product,
	   respectively, of mp1 and mp2 in rmp.

     void mdiv(const MINT *nmp, const MINT *dmp, MINT *qmp, MINT *rmp);

     void sdiv(const MINT *nmp, short d, MINT *qmp, short *ro);

	   mdiv() computes the quotient and remainder of nmp and dmp and
	   stores the result in qmp and rmp, respectively.  sdiv() is similar
	   to mdiv() except the divisor (dmp or d) and remainder (rmp or ro)
	   the result of bmp raised to the eth power and stores the result in
	   rmp.

     void min(MINT *mp);

     void mout(const MINT *mp);

	   min() reads a line from standard input, tries to interpret it as a
	   decimal number, and if successful, stores the result in mp.	mout()
	   prints the value, in decimal, of mp to standard output (without a
	   trailing newline).

     void gcd(const MINT *mp1, const MINT *mp2, MINT *rmp);

	   gcd() computes the greatest common divisor of mp1 and mp2 and
	   stores the result in rmp.

     int mcmp(const MINT *mp1, const MINT *mp2);

	   mcmp compares the values of mp1 and mp2 and returns 0 if the two
	   values are equal, a value greater than 0 if mp1 is greater than
	   mp2, and a value less than 0 if mp2 is greater than mp1.

     void move(const MINT *smp, MINT *tmp);

	   move() copies the value of smp to tmp (both values must be initial-
	   ized).

     void msqrt(const MINT *nmp, MINT *xmp, MINT *rmp);

	   msqrt() computes the square root and remainder of nmp and stores
	   them in xmp and rmp, respectively.


IMPLEMENTATION NOTES

     This version of libmp is implemented in terms of the crypto(3) BIGNUM
     library.


DIAGNOSTICS

     Running out of memory or illegal operations result in error messages on
     standard error and a call to abort(3).


SEE ALSO

     abort(3), bn(3), crypto(3), free(3), malloc(3), math(3)


HISTORY

     A libmp library appeared in 4.3BSD.  FreeBSD 2.2 shipped with a libmp
     implemented in terms of libgmp.  This implementation appeared in
     FreeBSD 5.0.


BUGS

     The pow() routine exists in both libmp and libm with incompatible seman-
     tics.

     Errors are reported via output to standard error and abnormal program
     termination instead of via return values.	The application cannot control
     this behavior.

     It is not clear whether the string returned by mtox() may be written to

SPONSORED LINKS




Man(1) output converted with man2html , sed , awk