Support for signaling NaNs?

In Julia generally missing is favored over NaN, among other because NaN work only for floating point types, and because the origin of NaNs can be hard to trace once they have infected the data.

However, IEEE745 has also signaling NaNs, supported in C++11, but not in Julia at least not “officially”. I found this discussion where also a solution for Linux/x86 is outlined. A problem seems to be that LLVM (still?) does not support hardware exceptions? Is there any updated “insider” information which I have not been able to find? A package for at least Linux/x86?

Having worked with various hardware that signals when something is wrong I presume that the signaling NaNs would be a good and efficient solution in many cases when computations are within floating points.

3 Likes

Code for “add floating point environment to task state” issue has been added (and that issue closed): add fenv cache to task struct by simonbyrne · Pull Request #51288 · JuliaLang/julia · GitHub

See also open issue, and code there:

I tried the code … :

julia> setfpexceptions(FE_DIVBYZERO, FE_INVALID, FE_OVERFLOW) do
           1/0.0 # your code here
       end
Inf

This did not work, as I thought it would, because it’s evaluated at compile time, but with real code doing such it does.