This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC and Floating-Point


Vincent Lefevre wrote:

On 2005-05-24 09:04:11 +0200, Uros Bizjak wrote:


I would like to point out that for applications that crunch data
from real world (no infinites or nans, where precision is not
critical) such as various simulations, -ffast-math is something that
can speed up application a lot.



But note that even when precision is not critical, you may get consistency problems or annoying unintuitive side effects. For instance, see

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15134

where

float x = 30.0;
int main()
{
 if ( 90.0/x != 3.0)
   abort();
 return 0;
}

fails with -ffast-math (on x86). I would not recommend it, unless
the user knows all the consequences.



On the other hand, in general using != and == on floating point numbers is always dangerous if you do not know all the consequences. For example, on your above program if I use 30.1 and 90.3, the program fails without -ffast-math.

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]