[comp.sys.mac.programmer] Integer Arithmetic

gregh@inmet.inmet.com (01/22/90)

Recently, I've come up against the limits of integer representation
on the Mac. While 2^63 - 1 may seem like a big number, it is wholly
inadequate for performing such calculations as predicting the base
price of the rumored Mac IIxi :-).

I'd like to find a THINK C library for performing unlimited (also
known as multiple precision) integer arithmetic. Failing that, portable
C source code would be nice, and if that doesn't work, I'd be happy
with some good reference material on writing my own.

Thanks,

Greg Herlihy
uunet!inmet!gregh
~

alms@cambridge.apple.com (Andrew L. M. Shalit) (01/30/90)

In article <32600005@inmet> gregh@inmet.inmet.com writes:

   Recently, I've come up against the limits of integer representation
   on the Mac. While 2^63 - 1 may seem like a big number, it is wholly
   inadequate for performing such calculations as predicting the base
   price of the rumored Mac IIxi :-).

   I'd like to find a THINK C library for performing unlimited (also
   known as multiple precision) integer arithmetic. Failing that, portable
   C source code would be nice, and if that doesn't work, I'd be happy
   with some good reference material on writing my own.

Are you tied to C?  If not, there are (at least) three Lisp's for the
Macintosh which support `bignums' (unlimited size integers).  Macintosh
Allegro Common Lisp takes about 1.5 seconds to calculate (FACTORIAL 1000)
on a Mac II.  (the resulting number is greater than 2^8529 :-).

If you need to stay in C, you could check out the T sources for their
bignum implementation.  T is a publicly distributed implementation
of Scheme which was done at Yale.  The sources are probably available
by ftp.  You could ask around in comp.lang.lisp or comp.lang.scheme.
Other references are probably available, as well.

Hope this helps.

     -andrew

gillies@p.cs.uiuc.edu (02/11/90)

Re:  C Source for infinite precision.

If you can get a hold of a UNIX machine with a source license, look at
the source to the ulimited-precision BC calculator.

oster@dewey.soe.berkeley.edu (David Phillip Oster) (02/12/90)

The usenet source code archives have at least one "inifinite" precision
math package. It can be ported to the Mac with little problem.