|
Boost : |
From: Dan Nuffer (dnuffer_at_[hidden])
Date: 2000-09-21 09:35:15
Beman Dawes wrote:
>
> At 03:38 PM 9/20/2000 -0600, Dan Nuffer wrote:
>
> >A few years ago I wrote a class like this. It acts like a signed
> >integer and the range is only limited to the amount of memory you have.
> >You can download it from:
> >http://students.cs.byu.edu/~nuffer/bigint.h
> >http://students.cs.byu.edu/~nuffer/bigint.cpp
> >
> >I placed it into the public domain, and anyone is free to use it. If
> >there is interest, it could be cleaned up and submitted to boost. It
> >also needs some performance work, as I took the straightforward, easy to
> >code approach and didn't do any fancy algorithms.
>
> Dan,
>
> Did you look at Daryle Walker's
> http://www.egroups.com/files/boost/bitint.zip posting?
>
> Did your classes have any advantages over Daryle's?
>
> --Beman
Yes. The number of bits in bitint is fixed at compile time. My bigint
class dynamically allocates memory as needed. Allowing the user to
store a number as large as you have memory. There are situations where
bitint is a more appropriate solution, and others where bigint is
better. For example, say you wanted to write a program to compute
factorials. You don't know how big of a factorial the user wants to
compute until run-time, so my class would be the appropriate solution in
that case. Given enough memory and time, one could compute the
factorial of 1,000,000,000,000. Looking back, I think I created this
class to use when messing around with Ackermann's function, but it ended
up not being much help because Ackermann's function takes a LONG time to
compute for almost any values. Anyway, there are a few things that need
cleaning up (operator <<) but all of the functionality of an integer is
present, debugged and free for anyone to use.
--Dan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk