[PPL-devel] Re: Precision of doubles and stdio

Larrie Carr larrie at telus.net
Sun Mar 5 18:51:30 CET 2006


There was discussion last year on something similar.  Even though the code 
bases are similar, there are differences between mingw, cygwin and linux 
base code at the lower levels that are beyond my area of expertise.

 http://www.cygwin.com/ml/cygwin/2005-07/msg00177.html

You will probably find that your linux and cygwin use different C libraries 
(newlib versus glibc or others) or different versions where the lower level 
functions like fesetround or strtod operate differently.  Some digging will 
probably pop out the answer.

I'm a lurker on the list so this is the limit of my help.

Larrie.

From: "Roberto Bagnara"
> Hi there,
>
> the following little program
>
> #include <stdio.h>
>
> int main() {
>   double d;
>   scanf("%lf", &d);
>   printf("%.1000g\n", d);
>   return 0;
> }
>
> does this on Linux/i686
>
> $ gcc -W -Wall in.c
> $ a.out
> 70.9
> 70.900000000000005684341886080801486968994140625
>
> and does the following under Cygwin on the same machine:
>
> roberto at quark /tmp
> $ gcc -W -Wall in.c
>
> roberto at quark /tmp
> $ ./a.exe
> 70.9
> 70.90000000000000568434188608080148696899414
>
> Why?  Is there a way to reconcile the two behaviors?
> Notice that I know about the x87 and its vaguaries:
> nonetheless I wonder why such a scanf immediately
> followed by a printf shows a difference between
> Cygwin and Linux.
> All the best,
>
>     Roberto

Wouldn't this old discussion apply.

http://www.cygwin.com/ml/cygwin/2005-07/msg00177.html





More information about the PPL-devel mailing list