Linked by Thom Holwerda on Fri 3rd Feb 2012 23:43 UTC
PDAs, Cellphones, Wireless There's an article making the rounds right now about how applications on iOS crash more often than applications on Android. I'm not going to detail the entire methodology - the article itself does so - but it does raise an interesting talking point about how both mobile operating systems handle application crashes and updates.
Permalink for comment 505965
To read all comments associated with this story, please click here.
MORB
Member since:
2005-07-06

Handling a division-by-zero error in C++ is trivial. Subclass std::runtime_error and handle it like you would any other exception.

Only if you're using visual C++ and their silly structured exception handling, which is pretty bad for various reasons, including performances. Throwing an exception on a division by zero is non standard behavior.

Also, a division by 0 won't necessarily cause the program to halt. If you work with floats it will usually just yield a special type of NaN value indicating an infinite.

The best way to deal with divisions by 0 is to special case the situations where they can happen, or assert if it is never supposed to happen.
If you don't explicitly deal with the division by 0 cases it can result in either a crash (that includes uncaught exceptions) or bugged behavior, in absolutely any language.

Edited 2012-02-05 14:49 UTC

Reply Parent Score: 2