[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Double vs Long Double
From: |
Martin Jansche |
Subject: |
Re: [Help-gsl] Double vs Long Double |
Date: |
Sat, 29 Sep 2007 13:03:13 -0400 |
Most parts of the public API of GSL use double precision, so you're
limited to 53 significant binary digits. That means 53*log(10)/log(2)
~= 15.95 decimal digits. If you want to interpret results in decimal,
you should print them out with no more than 15 (or more properly the
value of DBL_DIG) significant decimal digits, e.g. using the format
string "%.15g". The only reason to use more decimal digits is if you
want safe round-trip conversion from binary to decimal and back. If
you want to make sure you got exactly the same double value, print it
out in hex ("%a"), or binary for debugging. Long story short, you're
getting exactly the same result as in the documentation.
-- mj
On 9/28/07, address@hidden <address@hidden> wrote:
> I just got the GSL book today and immediately
> tried the sample program on page 9.
>
> I did not get the exact same answer shown in the book:
> JO(5) = -1.775967713143382920e-01
> I got J)(5) = -1.775967713143382642e-01
> ^^^
> I'm running 64-bit AMD OpenBSD 4.1 on AM2 Athlon 64.
>
> gcc (GCC) 3.3.5 (propolice)
> Copyright (C) 2003 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> FP computation is done using MMX registers except for long double which
> is done using the 8087 registers. I am now working on a version of GSL
> compiled using long double to force use of the 80-bit FP data format
> and see if I get the result listed in the book.
>
> Comments?
>
> Thanks,
> Dave Feustel
>
> --
>
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
>