Re: printf and long double

Chrysostomos Nanakos <[email protected]>
Newsgroups gmane.linux.c-programming
Message-ID <[email protected]>
  On 4/10/2010 4:33 πμ, Glynn Clements wrote:
> Nanakos Chrysostomos wrote:
>
>> I have the above C code snippet. I am trying to get a resonable
>> result in a fixed form with printf for a long double value but with
>> no luck. What am I doing wrong?
>> 	long double c = powl(10.0L,30.0L);
>>
>> 	printf("%llf %lle\n",c,c);
> On x86, long double is 80 bits, which is roughly 24 decimal digits.


I wish I could get 24 decimal digits precision with the current long 
double (80-bit). I can't get more than 15 digits even in a simple division.
I think that the extended-precision can't give more than 19 decimal 
digits of precision (log(10,2^64)=19.2). The quadruple precision can 
give at most 34 decimal digits (log(10,2^113)=34).

Please consider the example below:
--------------------------------------------------
long double a = 1.0L/7.0L;
printf("%Lf\n",a);
--------------------------------------------------

Can't get more than 15 digits precision....-:(
Is this a compiler problem or libc's problem? In x86_64 machines the 
long double values supposed to give at least 106-bit precision even when 
implemented in software. Is gcc compliant with the quadruple notation?




> The -m128bit-long-double flag only changes the alignment, not the
> accuracy of the calculations.
>
> The only reason why you're getting different results for %f and %e is
> that the default precision of 6 refers to 6 decimal places for %f but
> to 6 significant digits for %e.
>

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.