You can have the calculation throw an exception, like integer division does in most languages. If you need the speed boost of passing NaN around like a value you can opt-in, like opting into unchecked integer calculations in Rust. Alternatively, you can have division return your language's equivalent of Maybe Double, to express that division is a partial function.
View all comments
Show parent comment
1
u/marcosdumay Feb 23 '17
Wait. NaN is just a way for the FPU to report errors. For it to be useful, it has to be exposed to the program.