Re: Question on performance
On Oct 15 2010, Vincent Lefevre wrote:
On 2010-10-15 06:37:54 -0400, Michel Hack wrote:
> ... It's strange that GCC doesn't replace isnan() by a test x != x
Perhaps because these are NOT equivalent?
I think they are on conforming code.
Oh, no, they're not - not even remotely!
Mainly, unless the implementation defines __STDC_IEC_559__ to be 1, the
latter is undefined behaviour and the former (probably) isn't. Let's
ignore the multiple ambiguities in the standard here, and concentrate on
what most people understood to be the intent when C99 was standardised.
Also, if FLT_EVAL_METHOD is negative, the behaviour is of the former is
implementation-dependent (and may be undefined) but not the latter.
You didn't want to know any of that, did you? There's lots more where
that came from :-(
Regards,
Nick Maclaren.