This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Serious bug
- To: Kamil Iskra <kamil at dwd dot interkom dot pl>
- Subject: Re: Serious bug
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Wed, 30 Sep 1998 09:36:36 +0100
- Cc: egcs at cygnus dot com
- Cc: rearnsha at sun52 dot arm dot com
- Organization: ARM Ltd.
- Reply-To: richard dot earnshaw at arm dot com
kamil@dwd.interkom.pl said:
> Not to me. I was taught NEVER to use == or != with floating point,
> because they simply don't make sense. Too bad that C[++] standard
> allows them.
Actually, in ieee754 == and != have one very important use: they can be
used to test for a NaN without causing a fault.
double a;
...
if (a != a)
{
/* Code to deal with a NaN */
}
Comparing different floating point numbers for (in)equality is definitely
a no-no.
Richard