They “raise exceptions” in the IEEE 754 sense, which is not at all the same thing as what most programming languages mean by “raise exception”. It means that they set a sticky flag in a register that may be queried at a later point, not that program control flow is redirected.
The only use I saw for this is that you can enable compiler flags to crash the program when NaNs are encountered. Useful for testing Fortran code, in my experience. I didn’t see any support for other languages I’ve used.
C lets you set and query the flag state with the `<fenv.h>` functions in theory, but compiler support for rigorously adhering to IEEE 754 semantics around these operations is pretty limited in most compilers, to say the least. Clang has been making some progress on support recently.
Well, you test for it by comparing the value against itself and seeing if that returns false.
(There’s also a bit of confusion on by value vs. by reference comparison and the actual bit value on a NaN, which isn’t quite right.)