delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/11/10/13:40:06

From: khan AT xraylith DOT wisc DOT edu (Mumit Khan)
Subject: Re: cygwin-b20 gcc: "A - floor(A)" returns a negative value
10 Nov 1998 13:40:06 -0800 :
Message-ID: <9811100803.AA14874.cygnus.gnu-win32@modi.xraylith.wisc.edu>
References: <000001be0b8a$16397810$f445ce84 AT ECE DOT McGill DOT CA>
To: "Peter Kabal" <Kabal AT ece DOT mcgill DOT ca>
Cc: gnu-win32 AT cygnus DOT com

"Peter Kabal" <Kabal AT ece DOT mcgill DOT ca> writes:
> Switching from cygwin-b19 to cygwin-b20 caused a C-routine to give
> incorrect results.  This was traced to a calculation (in double) of
> "A - float(A)" which returns a negative value.  By definition it should
> always be positive.  A short test program which demonstrates this
> problem is included.  If the program is further simplified, the problem
> goes away.  To exercise the bug, the program must be compiled with
> optimization level -O3.
> 
> % gcc -O3 tfloor.c -o tfloor
> % ./tfloor
> AV = 20, AV - floor(AV) = -1.11022e-15

The suggestion is to use -ffloat-store to tell egcs not to use the excess
precision in the x86 FP regs. It does give the correct results then.

Thanks for pointing this out. I'm now adding this as a standard flag to
all of our numerical codes.

Regards,
Mumit
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019