This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: for loop: different results on cygwin and on linux
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: Lemaitre Laurent-r29173 <Laurent dot Lemaitre at freescale dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 3 Jul 2007 20:32:13 +0200
- Subject: Re: for loop: different results on cygwin and on linux
- References: <644FBC2A9A0CD44A83D429031B3A94A6876994@zfr11exm20.fsl.freescale.net>
On Tue, Jul 03, 2007 at 07:01:21PM +0200, Lemaitre Laurent-r29173 wrote:
> 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.
The difference is expected for floating point numbers.
> 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)?
Depending on what you think is the correct result, write the for() loops
like this
for (v=0.0;v<1.25;v+=0.5)
;
for (v=1.0;v<0.95;v+=0.1)
;
or like this
for (v=0.0;v<0.75;v+=0.5)
;
for (v=1.0;v<1.05;v+=0.1)
;
--
Rask Ingemann Lambertsen