This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Precision of doubles and stdio
- From: Roberto Bagnara <bagnara at cs dot unipr dot it>
- To: cygwin at cygwin dot com
- Cc: The Parma Polyhedra Library developers' list <ppl-devel at cs dot unipr dot it>
- Date: Fri, 03 Mar 2006 22:43:34 +0100
- Subject: Precision of doubles and stdio
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@quark /tmp
$ gcc -W -Wall in.c
roberto@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
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara@cs.unipr.it
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/