4 ms·
Do you count under/overflow resulting in Inf as 'something has gone wrong'? If so, why would gracefully recovering be hard?
by ImprobableTruth 5y ago
Do you count under/overflow resulting in Inf as 'something has gone wrong'? If so, why would gracefully recovering be hard?
- vanviegen 5y agoBecause you're about 15 stack frames deep into some calculation when the problem gets noticed. So how do you handle this? You could throw an exception (or similar), which would allow the UI to state something semi-helpful like 'Calculation failed'. But recover? Usually not. I think NaN and inf can be really useful in specific cases, but they probably shouldn't be allowed to propagate through your program, and shouldn't occur unless you're specifically making use of them.
- adrian_b 5y agoWhen you do not want such values to be propagated, it is always possible to choose to have overflow exceptions instead of infinities and undefined operation exceptions instead of NaNs. Also underflow exceptions instead of denormals. The programmer should choose which is most appropriate for an application. Choosing to both ignore the exceptions and not generate a special value that can be examined later, that is seldom acceptable.