Usable and reliable is not the same thing as good design or good idea.
The fact that Windows reserves the PRN file name in every directory is probably usable and reliable to someone. That doesn't mean it's a good design for providing access to a printer device.
To test a set membership property of an object, you want a predicate function which takes the object as its only argument. For instance isnan(x).
This predicate can be efficiently implemented without relying on a bastardized equality operation.
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.)
Comments
Among other things, this is super useful insofar as it gives a reliable way to test for NaN.
Usable and reliable is not the same thing as good design or good idea.
The fact that Windows reserves the PRN file name in every directory is probably usable and reliable to someone. That doesn't mean it's a good design for providing access to a printer device.
To test a set membership property of an object, you want a predicate function which takes the object as its only argument. For instance isnan(x).
This predicate can be efficiently implemented without relying on a bastardized equality operation.
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.)