[erlang-questions] Division by Zero
Thu Nov 15 15:03:04 CET 2012
I suggest three things.
1. If you are wrestling with really a higher order problem of dealing with abstract things like infinity then I suggest that you define your own number type and provide your own math functions that are well behaved in such situations, return 'infinity' for example from a custom divide(X, Y) function or some such ilk,
2. Use a guard to detect the 0 as early as possible in your code, preferably at the first point you can determine that a 0 would lead to disaster. That way the div0 would be a function clause error and you could spot the problem earlier.
3. Wrap code in a try-catch. Icky.
On Nov 15, 2012, at 7:47 AM, Valentin Micic <> wrote:
> Did you consider not dividing by zero?
> On 15 Nov 2012, at 3:42 PM, Lucky Khoza wrote:
>> Hi Erlang Developers,
>> How do i resolve division by zero errors in Erlang.
>> Kindest Regards
>> erlang-questions mailing list
> erlang-questions mailing list
More information about the erlang-questions