linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chrysostomos Nanakos <nanakos@wired-net.gr>
To: Glynn Clements <glynn@gclements.plus.com>,
	linux-c-programming@vger.kernel.org
Subject: Re: printf and long double
Date: Mon, 04 Oct 2010 14:54:46 +0300	[thread overview]
Message-ID: <4CA9C086.1050401@wired-net.gr> (raw)
In-Reply-To: <19625.11998.318578.160832@cerise.gclements.plus.com>

  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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-10-04 11:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-03 22:56 printf and long double Nanakos Chrysostomos
2010-10-04  0:43 ` Gedare Bloom
2010-10-04  1:44   ` Glynn Clements
2010-10-04  1:33 ` Glynn Clements
2010-10-04 11:54   ` Chrysostomos Nanakos [this message]
2010-10-04 12:03     ` Bogdan Cristea
2010-10-04 12:12       ` Chrysostomos Nanakos
2010-10-06 20:18       ` printf and long double [SOLVED] Nanakos Chrysostomos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CA9C086.1050401@wired-net.gr \
    --to=nanakos@wired-net.gr \
    --cc=glynn@gclements.plus.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).