By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,053 Members | 976 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,053 IT Pros & Developers. It's quick & easy.

Small High-precision Arithmetic Library

P: n/a
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

Jul 19 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
GCRhoads wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 19 '07 #2

P: n/a
GCRhoads wrote:
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.
--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jul 19 '07 #3

P: n/a
GCRhoads <GC******@volcanomail.comwrites:
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
Jul 19 '07 #4

P: n/a
On Wed, 18 Jul 2007 19:46:15 -0700, in comp.lang.c , GCRhoads
<GC******@volcanomail.comwrote:
>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
Jul 19 '07 #5

P: n/a
Mark McIntyre <ma**********@spamcop.netwrites:
On Wed, 18 Jul 2007 19:46:15 -0700, in comp.lang.c , GCRhoads
<GC******@volcanomail.comwrote:
>>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?
It could be either. He is clearly looking, one can assume, for a C or
C++ library to interface too.
Jul 20 '07 #6

P: n/a
On Jul 19, 11:26 am, Chip Coldwell <coldw...@gmail.invalidwrote:
GCRhoads <GCRho...@volcanomail.comwrites:
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
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/sof...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.

Jul 20 '07 #7

P: n/a
On Jul 19, 3:36 pm, Mark McIntyre <markmcint...@spamcop.netwrote:
On Wed, 18 Jul 2007 19:46:15 -0700, in comp.lang.c , GCRhoads

<GCRho...@volcanomail.comwrote:
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?
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

Jul 20 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.