for loop: different results on cygwin and on linux

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

 



Hi All,

Not sure if this is the right place to ask this question.
My apologies if not!
I am trying to build a testsuite that I want to run on different
platforms.
My testsuite uses the printf command and a for-loop. But depending on
the platform
I compile my program my code gives unexpected different results.
Below is an example that illustrates the problem.
$ cat printf.c
#include <stdio.h>
int main(void)
{
  double v;
  for (v=0.0;v<1.0;v+=0.5)
  ;
  printf("o %-1.6e\n",v);
  for (v=1.0;v<1.0;v+=0.1)
  ;
  printf("# %-1.6e\n",v);
  return 0;
}
which gives on windows (printf.c compiled using gcc version 3.4.4):
o 1.000000e+000
# 1.000000e+000

and on linux (printf.c compiled using gcc version 3.2.3):
o 1.000000e+00
# 1.100000e+00

Is-there any way to change the code so that I am sure I will get
identical
results on both platforms (cygwin and linux)?

Thanks,

Laurent 


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux