Hi Pshemek,
You are right. GSL indeed uses double and long double.
Thanks for pointing that.
However, consider this : (from
http://www.cuj.com/documents/s=8020/cuj0111ring/ Read the paragraph
"Why We Need Arbitrary Precision" for more details):
VerdanaFor example, consider the
two numbers N1 = 98237307.398797975997 and N2 =
87733164872.98273499749. N1 has 20 significant
digits; N2 has 22. If you assign these to C
doubles, each variable will maintain only 15-16 digits of
precision 0000,0909,6969(assuming 64
bits). If you then multiply these numbers, the result will be
precise only to the 15-16 most significant digits.
You can use GSL but then when you get a
GSL_ERANGE
(TimesGSL_ERANGETimes:
Range error; used by mathematical functions when the result value is
not representable because of overflow or underflow)
or other exception you will need to
handle this error.
If you are very careful and through on this error handling my opinion
is that you will probably end up writing your own version of an
arbitrary precision wrapper over GSL.
One interesting project might be to write a version of GSL with
templates that would allow the use of an arbitrary precision math
class instead of double.
I might be missing something here but this is getting off topic and I
think I should move to http://lists.gnu.org/mailman/listinfo/help-gsl
for further investigation.
Thanks,
Mauricio Gomes
Pensar Digital
phone: 55-11-4121-6287
mobile: 55-11-8319-9610
http://pensardigital.com
On Apr 18, 2005, at 5:11 AM, Sliwa, Przemyslaw (London) wrote:
Why not?
AFAIK GSL, one of the most important open source numerical libraries
uses double precision, so I do not see the point why you say double is
not good enough for scientific applications.
Regards,
Pshemek
-----Original Message-----
From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of Mauricio
Gomes
Sent: 17 April 2005 04:12
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] RE: Boost thread problem
Ben is right, you simply can't use double for any serious
financial/scientific calculation.
And indeed I hope someday an arbitrary math precision library be part
of the standard C++.
Look for a standard for the place where this is going to be used.
If there isn't one. Use an arbitrary math precision library anyway.
Take a look at mapm:
http://www.cuj.com/documents/s=8020/cuj0111ring/
http://www.tc.umn.edu/~ringx004/mapm-main.html
There are other comercial alternatives, a quick google search produced
this:
http://www.boic.com/b1mnum.pdf
http://www.boic.com/numintro.htm
Hope this helps,
Mauricio Gomes
Pensar Digital
phone: 55-11-4121-6287
mobile: 55-11-8319-9610
http://pensardigital.com
On Apr 15, 2005, at 2:37 PM, Ben Hutchings wrote:
Sliwa, Przemyslaw (London) wrote:
Thanks, Ben, what should I use for representing the money
amounts? A
boolean :)) ?
If you're dealing with other people's money then there are regulations
that specify the required intermediate precision and rounding
rules,
which may vary from place to place. I believe you'll need to use
fixed-point decimal fractions, perhaps implemented as integer counts
of hundredths or ten-thousandths of a currency unit. I've not done
this myself so I don't know the details, but I'm fairly sure that
getting this wrong can put you on the wrong side of the law.
Ben.
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
--------------------------------------------------------
If you are not an intended recipient of this e-mail, please notify the
sender, delete it and do not read, act upon, print, disclose, copy,
retain or redistribute it. Click here for important additional terms
relating to this e-mail. http://www.ml.com/email_terms/
--------------------------------------------------------
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users