3 ms·
Typically, divide by zero throws for integers because they can’t express NaN, which can instead be returned for floating point. In any case, integers can’t expr
by seanmcdirmid 8y ago
Typically, divide by zero throws for integers because they can’t express NaN, which can instead be returned for floating point. In any case, integers can’t express special values, so you get exceptions instead. And this is actually defined at the processor level (for x86 among others), the trap is free (well, a sunk cost), why not take it?
Zero is not a very good NaN.
- cousin_it 8y agoYeah, agreed. The thing with 1/0=0 is bizarre, I guess my comment was more about why NaNs are okay.