That's probably why the recent RISC-V architecture doesn't even give the option of raising an interrupt on floating point errors ("As allowed by the standard, we do not support traps on floating-point exceptions in the base ISA, [...]"). Going even farther, it also doesn't raise an interrupt on integer divide by zero (https://content.riscv.org/wp-content/uploads/2017/05/riscv-s...). That probably simplifies out-of-order implementations, since the only things that can trap then are the instruction decoder (instruction fetch errors and invalid instructions), the load/store instructions, and special instructions (system calls, breakpoints, and like).
(It also doesn't propagate NaN payloads, always returning the same canonical NaN whenever an operation produces a NaN).
These guys have never allreduced a timestep in a simulation where something can go aphysical.
I mean, sure, one can communicate aphysical conditions using out-of-band means. But it is so pretty when it just rides along for free as a NaN result.
Edit: I stand corrected having looked up authors. I still think having float effectively be Maybe[float] is a feature not a bug.
A closer analogue of NaN might be the x ("unknown") value in the three/four-valued logic of hardware simulation languages like Verilog. But the situation in Verilog, despite its challenges, is so much better since you don't have a hard discontinuity between "numbers" and "logical values". Numerical comparisons between unknowns can produce unknown logical values, and you have equations like true & unknown = unknown, true | unknown = true, ~unknown = unknown, etc, so you don't have the issue with NaNs where as soon as something crosses from the floating-point realm to the integer or logical realm, it has to commit to a definite value, with all the aforementioned issues.
All that said, NaNs were the right design choice given the constraints. But it's far from ideal.
I saw him explain that in float, there a too many bit representations that amount to "NaN". According to a Stack Overflow I found:
"IEEE 754 standard defines 16,777,214 32-bit floating point values as NaNs, or 0.4% of all possible values."
That's "expensive" in terms of losing bits of expressiveness that could have been used to represent actual numbers.
Cost of a Interrupt: 100 ns to 1 microseconds (Quora) Sorry, that solution is simply not interesting for most implementations where floats are used. There are sensors which in realtime hammer out so many values, that not using NaNs means dropping part of your sensor values.
This is a classic case of re-inventing a optimal wheel (fine for racing) and not really looking at the use-cases (not fine for a lot of normal day to day driving).
Im sure it will bring the groupies on conferences.
That sounds like the time it takes to do a context switch to the OS. A math error interrupt doesn't need to do a context switch. The cost doesn't need to be any higher than a branch misprediction at 10-20 cycles.
Thanks for putting it right, before the missinformation could spread.
The double precision floating point format already represents between 15 and 17 significant digits, and those who, for some reason, believe they need more expressiveness can already use the illusive and rarely needed 80-bit extended precision floating point format.
0.4% of anything is nothing.
That's ok, because NaNs are exceptional responses to numerical errors thrown during number crunching, indicating that something failed unexpectedly and the output is crap.
Or is that exception hard to implement?
https://github.com/interplanetary-robot/SigmoidNumbers/blob/...
That doesn't help if the result could be partially valid, but if a "square root of minus one" or similar anywhere in the calculation means the result is invalid (and would be a NaN under floating point), sticky error bits in a status register could be sufficient.
What a strange claim. Outputting a NaN is easier than raising an interrupt, or could be done within an interrupt, and detecting a NaN input requires a handful of gates or less.
This is not to say that NaNs are a good or bad method, but they're definitely not expensive to implement.
> posits lack a separate ∞ and −∞ [...] “negative zero” is another defiance of mathematical logic that exists in IEEE floats.
I will note that the IEEE standard almost had a projective infinity mode, and x87 has that mode.
> floats are asymmetric and use those bit patterns for a vast and unused cornucopia of NaN values
If we want to ignore languages like javascript and lua, sure.