Linked by Thom Holwerda on Fri 3rd Feb 2012 23:43 UTC
Thread beginning with comment 505965
To view parent comment, click here.
To read all comments associated with this story, please click here.
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[5]: You're wrong. It's bad iOS developers.
by BeamishBoy on Mon 6th Feb 2012 19:21
in reply to "RE[4]: You're wrong. It's bad iOS developers."
Only if you're using visual C++ and their silly structured exception handling, which is pretty bad for various reasons, including performances.
Eh? Any compiler with even a basic form of standards compliance can produce code that handles a division-by-zero exception. As I said, it's trivial to implement, coming in at a few lines of code.
Throwing an exception on a division by zero is non standard behavior.
Of course, but that's irrelevant to the point I was making, which is that division-by-zero is not necessarily fatal in C++. The OP was claiming this to be an inherent and irresolvable flaw in the language; I showed that the language provides you the tools you need to handle it if you so wish.
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.
"Dividing by zero" errors implicitly assume that you're working with integer types, at least in this neck of the woods. Surely everyone knows that it means something else when working with floats?




Member since:
2005-07-06
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