bug-coreutils
[Top][All Lists]
Advanced

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

Re: printf () bug?


From: Bob Proulx
Subject: Re: printf () bug?
Date: Wed, 24 Aug 2005 23:54:20 -0600
User-agent: Mutt/1.5.9i

Bill Schaffer wrote:
> Is there a printf() problem using 'long double' vs 'double' on 
> Windows Xp with i386?

You are probably talking about the printf(3) that is in libc.  The
mailing list you sent your message to is for the GNU coreutils,
formerly GNU shellutils.  Confusion with the standalone command
printf(1) command perhaps?  If so then please see this frequently
given answer for a stock reply:

  http://www.gnu.org/software/coreutils/faq/

Look for "I am trying to compile a C program program".

Bob

> printf( %.20lf  %.20Lf ) for 'double' and 'long double' variables
> result in both having 16-17 digits of precession.  Meaning sign 
> bit & 8 bit exponent, gives 64-8-1 = 55 bits of precession.
> 
>   2^55 = 3.6 * 10^16, or about 16 digits of precession.
> 
> Printing various examples shows 16 digit accuracy both though 
> 'sizeof(long double)' equals 12 bytes, and 'sizeof(double)' 
> equals 8.  (the '|' below indicates limit of accuracy).
> 
> 
> sizeof()          1.6867376747234567891345 Orginal
>                                   |
> 08 lf             1.68673767472345681462 16 digits
> 12 Lf             1.68673767472345681462
> 
>              161600.6867376747234567891  Orginal
>                               |
> 08 lf        161600.68673767472500912845 17 digits
> 12 Lf        161600.68673767472500912845
> 
>        123456789123.123456789123  Orginal
>                         |
> 08 lf  123456789123.12345886230468750000 17 digits
> 12 Lf  123456789123.12345886230468750000
> 
>       1234567891237.123456789123  Orginal
>                       |
> 08 lf 1234567891237.12353515625000000000 16 digits
> 12 Lf 1234567891237.12353515625000000000
> 
> Both types print the same. It seems 'long double' should give better
> precession.
> 
> Printf() problem?
> or compiler load of 'long double' constant problem?
> or 'long double' allocates 12 bytes but i386 handles only 8?
> 
> Or its just me.
> 
> Regards
> 
> Bill Schaffer
> _______________________________________________
> Bug-coreutils mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/bug-coreutils
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]