My best guess is that NaN's come from underflow, under normal circumstances. I wish there would be an easy way to change this behavior via a compiler flag, but I don't think there is.
It seems to be a more pervasive problem, and it's unreasonable to expect to add NaN handlers in application code. Thank the IEEE standards for this gem.
I did some more searching around to find that someone has written just such a handler for underflow here: http://www.cenapad.unicamp.br/parque/manuais/Ibmcxx/complink/tasks/tutrapex....
The code uses the sigcontext struct when a floating point exception occurs, to set the result to zero, once an underflow is created.
Underflow traps are enabled by (gcc) compiler flag -mfp-trap-mode=u
I'm really not sure about how all of this can be applied successfully. Has anyone implemented this kind of handler before?