3 ms·
If dividing by zero has a well defined result that doesn’t abort execution what exactly does “can’t” even mean? Operations on those sentinel values are also de
by epcoa 1y ago
If dividing by zero has a well defined result that doesn’t abort execution what exactly does “can’t” even mean?
Operations on those sentinel values are also defined. This can affect when checking needs to be done in optimized code.
- bee_rider 1y agoI believe divide-by-zero produces an exception. The machine can either be configured to mask that exception, or not. Personally, I am lazy, so I don’t check the mxcsr register before I start running my programs. Maybe gcc does something by default, I don’t know. IMO legitimate division by zero is rare but not impossible, so if you do it, the onus is on you to make sure the flags are set up right.
- epcoa 1y agoCorrect, divide by zero is one of the original five defined IEEE754-1985 exception. But the default behavior then and now is to produce that defined result mentioned and continue execution with a flag set ("default non-stop"). Further conforming implementations also allow "raiseNoFlag". It's well-defined is all that really matters AFAIC.