[comp.lang.c] Wanted: arbitrary precision integer arithmetic

msc_wers@jhunix.UUCP (Edward R Scheinerman) (12/02/86)

I am looking for subroutines that do basic arithmetic
(plus, minus, times, divide, modulus, input and output) with
very high (or even arbitrary) precision integers (up to about
200 digits). My preference is for C code (that will run under
UNIX System V), but FORTRAN is an acceptible alternative.

If you have such public domain source code, please send it
to me by e-mail at:

	msc_wers @ jhunix

Thank you!

-Ed Scheinerman				301-338-7210
 Department of Mathematical Sciences	msc_wers@jhunix
 The Johns Hopkins University		ers@hopkins
 Baltimore, Maryland 21218 USA

campbell@maynard.UUCP (Larry Campbell) (12/03/86)

In article <4056@jhunix.UUCP> msc_wers@jhunix.UUCP (Edward R Scheinerman) writes:
>
>I am looking for subroutines that do basic arithmetic
>(plus, minus, times, divide, modulus, input and output) with
>very high (or even arbitrary) precision integers (up to about
>200 digits). My preference is for C code (that will run under
>UNIX System V), but FORTRAN is an acceptible alternative.

The MP(3X) library routines, included in UNIX, do all this and more.

-- 
Larry Campbell       MCI: LCAMPBELL          The Boston Software Works, Inc.
UUCP: {alliant,wjh12}!maynard!campbell      120 Fulton Street, Boston MA 02109
ARPA: campbell%maynard.uucp@harvisr.harvard.edu     (617) 367-6846
DOMAINIZED ADDRESS (for the adventurous): campbell@maynard.BSW.COM

max@umnd-cs.UUCP (Max Benson) (12/04/86)

Last time I checked there remain serious bugs in the UNIX mp
library that remain from the PDP-11 days.  One was in the divide
routine that made it divide by zero for only certain large numbers.
This was because the exact integer representation wasn't normalized
at some point.  Another problem was that the in the add/subtract
routine it gets signs mixed up in one case.  I guess that the UNIX
programs that use mp don't ever find the add/subtract bug because
they remove the signs before getting to mp, but I imagine that the
divide bug is out there waiting for you in dc.  I found and tracked
down these bugs for my own purposes, but now I have written a new
library (in C, hopefully vanilla, currently runs on SUN, UMAX4.2) of
arbitrary precision integer arithmetic that is somewhat faster and
better yet public domain!  I can share this with those
interested.  It is part of a larger library of routines for symbolic
mathematics which will be eventually freely available once it is
documented.

Max Benson:  University of Minnesota-Duluth
max@umn-duluth.csnet
...!ihnp4!umn-cs!umd-cs!max

bs@linus.UUCP (Robert D. Silverman) (12/05/86)

I have a set of routines that beat the UNIX routines by over an order
of magnitude. These include not only +,-,*,/, but also things like
GCD's modular inverses, Jacobi symbol, modular exponentiation, etc. etc.
They are public domain and I use them in my factoring and prime testing
work. They run on SUN-3's and VAXEN and are 99% portable. They do use,
however 3 routines ~5 lines each to get at the ediv and emul instructions
and are written in assembler.

Bob Silverman

jpn@teddy.UUCP (John P. Nelson) (12/06/86)

>The MP(3X) library routines, included in UNIX, do all this and more.

It would be nice if you specified WHICH UNIX supplied them.  Mine doesn't
seem to.