Skip to content

Comment on An Interview with the Old Man of Floating-Point (1998)parent

Comments

Consider that the compiler cannot optimize A != A into false, or A == A into true, because NaN values can occur at run time.

While you might not explicitly write A == A into your code, it could occur implicitly due to some macro expansion, inline expansion or other code transformation.

I think GCC with -ffast-math gets rid of this NaN rule and does such optimizations anyway. (Your code just has to avoid generating NaNs so that the optimizations are valid.)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.