This is such a tremendous pain in the ass. Most code that has to do an "if this isn't zero, then divide" could be written to "just work" if it could generally assume that the CSRs were always set to flush. But they can't, because it usually isn't.
-
-
Show this thread
-
Since most numerical code today is in libraries, and libraries can't go setting the CSR because different libraries might conflict, etc., it is really a huge issue. Please someone just change this globally, by fiat. Microsoft? Linux? WASM? PLEASE???
Show this thread -
Maybe somebody has already, and if so, I commend you. But as far as I can tell so far, everybody still defaults to _crashing the program_ when it divides by zero.
Show this thread
End of conversation
New conversation -
-
-
Have you considered using std::stuff::divide_by_zero<std::types::platform_safe_int>(myInt, std::allocator::thrash_the_heap, std::exceptions::prefer_furbles) instead to shorten your code, and be more expressive and modern?
-
It's also a zero cost abstraction. It will add less than 2 minutes per int width to your compile time and can produce any of 11 different furble type exceptions for you to catch them all like Pokemons, and gain absolute control of your results
- Show replies
New conversation -
-
-
What is CSR? Google is not being helpful on it.
-
I believe it is supposed to stand for "Control Status Register", but I don't know if anyone actually defines that term in their manuals :) But it's the state in the processor that says how various operations should be dealt with, eg.:pic.twitter.com/O1gOwX3vXh
- Show replies
New conversation -
-
-
While we're at it: no math errno should have been the default for decades now. But back on topic I can't think of any reason a sane math library today would be depending on the exception.
-
...well excluding dynamic language runtimes.
End of conversation
New conversation -
-
-
The reason is the same as why denormals exist: people used to be more concerned with getting the correct result than having the program run fast or at all. Division by zero is a programming error like a segfault and should be treated as such.
-
Also while integer division by zero faults, FP division defaults to just returning a NaN. And that's the one the CSR affects.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.