Tom Forsyth

(replying to I Can't Believe It's Not Zero!)

@steve @mcc @hikari On x86, you can disable throwing actual exceptions on sNaNs. The MXCSR register has "sticky" bits that you can clear before a sequence, then check afterwards. If there were any sNaNs read or produced during the sequence, the "Invalid Operation" sticky bit will be set. I believe qNaNs do not set the sticky bits.

This is rather klunky to use, and relies on the language/library having support for reading/setting the MXCSR, but it can be done.

I Can't Believe It's Not Zero!

(replying to Tom Forsyth)

@TomF @mcc @hikari That's the default behavior; you have to _enable_ trapping on sNaN.

qNaN does not set sticky bits except for operations that have no other means to preserve the NaN: comparisons and conversions to integer.

(MXCSR defaults to 0000_1F80h, i.e. all exceptions masked)