Re: Getting greatest decimal accuracy out of G_PI



On Sat, Feb 03, 2007 at 12:34:24PM -0500, zentara wrote:
> 
> I'll post this in case anyone in the future searches the archives
> for an answer.

For the case anyone finds this, a correction...

You can't fool C.  The literal without an `l' suffix is
a double literal.  The compiler creates a floating point
constant represented by a double from it.  Passing it as an
argument to a function that takes long double results in
an automatic conversion to long double according to the
rules, but since it was double constant, is has still only
the preision of a double.  As your own example clearly
demonstrates.

> Output:
> PI is   3.1415926535897931159979634685441851615905761718750000000000000
> G_PI is 3.1415926535897931159979634685441851615905761718750000000000000

Input was 3.1415926535897932384626433832795028841971693993751
Counting matching digits:
          1 234567890123456X

So, the precision is 16 digits, in other words, the precision
of normal IEEE double.

> One other point though, g_print won't accept the mpfr_t as a long double,
> so the "%Lf" format won't work.

And why on Jupiter it should?  mpfr_t is not long double.

Yeti


--
Whatever.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]