3 ms·
Well if the language is flexible enough it doesn't have to be a big annoyance to have types for both fp32 and nnfp32 (no-NaN fp32). nnfp32 guarantees things tha
by jfries 9y ago
Well if the language is flexible enough it doesn't have to be a big annoyance to have types for both fp32 and nnfp32 (no-NaN fp32).
nnfp32 guarantees things that a fp32 doesn't, for example that comparison is always legal and works as expected.
This way you can perform calculations on fp32, but then have to sanitize the output before storing it back in the data structure.
One way to use the type system to enforce sanitation could be if values in a database are of type nnfp32, and the only way to produce a nnfp32 is using a function which returns Option<nnfp32>, returning Some only if the value is not NaN.