FP comparisons, C, X86, and NaN's
Chris Lattner
sabre@nondot.org
Sun Jun 20 07:14:00 GMT 2004
On Sun, 20 Jun 2004, Gabriel Dos Reis wrote:
> > I'm trying to understand the standards relating to floating point
> > comparisons in C, particularly with respect to NaN's. From my
> > interpretation of the whole mess, in C99, standard relational operations
> > (like X < Y) should trap on NaN's, including SNaNs.
>
> QNaNs don't trap, but would obey non-standard logic. SNaNs would
> trap. More specifically, the C99 standard says:
> 5.2.4.2.2/3
That is an interesting section, thanks for pointing it out.
> > 2. C does not define whether or not standard relational operations trap.
> > If this is the case, there is no bug in GCC.
So you are saying that this is the case: it is undefined whether an
implementation traps on a comparison with nans? This is my interpretation
of this passage:
> -- is true. Relational operators may raise the
> ``invalid'' floating-point exception when argument values
> are NaNs.
I just want to make sure that I'm intepreting things correctly.
Thanks for the input!
-Chris
--
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/
More information about the Gcc
mailing list