Re: Getting greatest decimal accuracy out of G_PI
- From: David Nečas (Yeti) <yeti physics muni cz>
- To: gtk-list gnome org
- Subject: Re: Getting greatest decimal accuracy out of G_PI
- Date: Sat, 3 Feb 2007 21:44:12 +0100
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
> PI is 3.1415926535897931159979634685441851615905761718750000000000000
> G_PI is 3.1415926535897931159979634685441851615905761718750000000000000
Input was 3.1415926535897932384626433832795028841971693993751
Counting matching digits:
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.
] [Thread Prev