Thread with 17 posts
jump to expanded postdoes anyone actually use sNaNs
@hikari I considered using a quiet NaN once for storing nulls for a database. I don't see much use for a signalling NaN. In that case, an actual error value seems preferable.
@hikari i'm not even sure which, if any, of the systems i've ever used/developed for actually support the signaling features.
@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.
@steve @mcc @hikari my favorite part is when people work hard to write explicit nan checks and handling, which then immediately get thrown away by the compiler. (which leads to a fun escalating war of detecting nan in obtuse ways, I'm sure some smartass in compiler land is going to get clever with bit patterns one day and break all the explicit via-integer checks too, this is all only in internal builds, at least, but it's a bit funny)
@hikari Some Common Lisp implementations do, and convert the HW exception to regular conditions.