Re: divide by zero error
- Posted by SDPringle Mar 21, 2009
- 1325 views
Look this is just a problem of what should be done with non-sense calls or expressions:
- return an error code using the classical return found in everywhere or exception mechanism seen in java and c++?
- crash the program?
- signal an error at compile time if possible first then one of the former two if not?
They all have their advantages. I'm with you though, return an error code let the caller handle the exception with the modification of the third option above. Either way you need to check something: For the crash strategy it is before each call for bad inputs and in the return policy it can be after several calls for nonsensible outputs.
Shawn Pringle