At some point, someone is going to have to explain why - despite nobody ever wanting this in production code ever, for any reason - the default CSR state for divide by zero on most platforms is fault instead of flush.
-
Show this thread
-
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.
1 reply 0 retweets 16 likesShow 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???
1 reply 0 retweets 13 likesShow 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.
2 replies 0 retweets 12 likesShow this thread -
Replying to @cmuratori
Maybe I'm misunderstanding: what would you like the following code to do? int x = 2 / 0; cout << x;
1 reply 0 retweets 0 likes -
Replying to @JaneSchwartz100
It's not what I would like it to do, it's what it _does_ do provided you set MXCSR properly (or the equivalent on other CPUs). With div-by-zero/underflow turned off, and flush-to-zero turned on, 2/0 = 0. So your code would print 0.pic.twitter.com/ju2q6BIfv5
1 reply 0 retweets 1 like
The only reason it _doesn't_ do that by default is because - for some truly bizarre reason - the default setting for MXCSR is to fault on divide by zero. Even though that is basically never what you want, unless you are debugging.
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.