[erlang-questions] Division by Zero

Eric Newhuis enewhuis@REDACTED
Thu Nov 15 15:03:04 CET 2012


LOL

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 <valentin@REDACTED> wrote:

> Did you consider not dividing  by zero?
> 
> V/
> 
> 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
>> Lucky
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list