Small High-precision Arithmetic Library

G

GCRhoads

I'm looking for a very basic high-precision arithmetic library. I
need to be able to specify a fixed number of bits or decimal digits
(32 decimal digits should be all I need). The only arithmetic
functions I need are addition, subtraction, multiplication, division,
square-root, and comparison (i.e. less-than, greater-than, equal).
Preferably this should be in C++ but I could use C by putting
everything into a single class. I looked at a couple of packages but
they were massive in size, a huge overkill for my needs. I don't need
arbitrary precision, FFT-based multiplication, etc. I could write my
own package but this task seems like a common enough need that I would
be surprised if there aren't some freeware or shareware packages much
more suited to my needs. Any suggestions on an efficient small
package that handles a fixed number of digits?

If you want to respond by email, then use the following email address
(I use the volcanomail address only for reading and posting to
newsgroups and other public forums -- to avoid spammers.)

rhoads "at" cs "dot" rutgers "dot" edu
 
V

Victor Bazarov

GCRhoads said:
I'm looking for a very basic high-precision arithmetic library. I
need to be able to specify a fixed number of bits or decimal digits
(32 decimal digits should be all I need). The only arithmetic
functions I need are addition, subtraction, multiplication, division,
square-root, and comparison (i.e. less-than, greater-than, equal).
[..]

If you use a template library, your compiler will only create code
for the functions you use. Advice: try to avoid setting the limits
for yourself ahead of time, remember what happened to "640 Kbytes
should be enough for anybody"?

Take a look at CGAL, as part of it there is a numeric kernel that is
(AIUI) programmed as templates and contains part with arbitrary
precision floating points. It may be too much for your small task,
then look into OONumerics. Also, I searched for "arbitrary precision
floating point template" for you on Google and the first link that
comes up also looks promising.

Try not to cross-post to c.l.c++ AND c.l.c.

V
 
C

Chip Coldwell

GCRhoads said:
I'm looking for a very basic high-precision arithmetic library. I
need to be able to specify a fixed number of bits or decimal digits
(32 decimal digits should be all I need). The only arithmetic
functions I need are addition, subtraction, multiplication, division,
square-root, and comparison (i.e. less-than, greater-than, equal).
Preferably this should be in C++ but I could use C by putting
everything into a single class. I looked at a couple of packages but
they were massive in size, a huge overkill for my needs. I don't need
arbitrary precision, FFT-based multiplication, etc. I could write my
own package but this task seems like a common enough need that I would
be surprised if there aren't some freeware or shareware packages much
more suited to my needs. Any suggestions on an efficient small
package that handles a fixed number of digits?

If you want to respond by email, then use the following email address
(I use the volcanomail address only for reading and posting to
newsgroups and other public forums -- to avoid spammers.)

rhoads "at" cs "dot" rutgers "dot" edu

Do you know about D. H. Bailey's work?

http://crd.lbl.gov/~dhbailey/

See, especially his ARBPREC package:

http://crd.lbl.gov/~dhbailey/mpdist/index.html

Chip
 
C

Clever Monkey

GCRhoads said:
I'm looking for a very basic high-precision arithmetic library. I
need to be able to specify a fixed number of bits or decimal digits
(32 decimal digits should be all I need). The only arithmetic
functions I need are addition, subtraction, multiplication, division,
square-root, and comparison (i.e. less-than, greater-than, equal).
Preferably this should be in C++ but I could use C by putting
everything into a single class. I looked at a couple of packages but
they were massive in size, a huge overkill for my needs. I don't need
arbitrary precision, FFT-based multiplication, etc. I could write my
own package but this task seems like a common enough need that I would
be surprised if there aren't some freeware or shareware packages much
more suited to my needs. Any suggestions on an efficient small
package that handles a fixed number of digits?
Googling "high precision arithmetic library" should yield something
useful to you.

Off the top of my head, there is GMP.
 
M

Mark McIntyre

I'm looking for a very basic high-precision arithmetic library.

This isn't either a C or C++ question - did you try googling? Or
asking in comp.programming?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
R

Richard

Mark McIntyre said:
This isn't either a C or C++ question - did you try googling? Or
asking in comp.programming?

It could be either. He is clearly looking, one can assume, for a C or
C++ library to interface too.
 
U

user923005

Do you know about D. H. Bailey's work?

http://crd.lbl.gov/~dhbailey/

See, especially his ARBPREC package:

http://crd.lbl.gov/~dhbailey/mpdist/index.html

Right link, wrong package.
If he wants 32 digits, then QD is the package:
http://crd.lbl.gov/~dhbailey/mpdist/qd-2.2.5.tar.gz
For Windows users, try this implementation:
http://www.cs.berkeley.edu/~yozo/software/qd-2.2.4-windll.zip

ARPREC is for gazillion digit stuff. The QD package has double double
and quad double, which sounds like it is right in the O.P.'s
wheelhouse.
 
U

user923005

This isn't either a C or C++ question - did you try googling? Or
asking in comp.programming?

I agree that Google is the best bet.
SourceForge is always worth a look.
And if those do not pan out, then this sort of thing is suited to
news:sci.math.num-analysis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top