[erlang-questions] Division by Zero

James Rosenblum <>
Thu Nov 15 15:07:45 CET 2012


Valentin's very perceptive comment aside, you could use one of the two error handling mechanisms as in:


case catch A/N of
{'EXIT', {badarith,_}} ->
    io:format("Some error statement or whatever!~n",[]);
Normal -> Normal
    end.

or

try A/N 
    catch
error:badarith ->
    io:format("some statement or whatever ~p/~p~n",[A,N]);
Normal -> Normal
    end.

I'm not positive, but it seems like you might not be aware of these error handling mechanisms 


________________________________
 From: Valentin Micic <>
To: Lucky Khoza <> 
Cc:  
Sent: Thursday, November 15, 2012 8:47 AM
Subject: Re: [erlang-questions] Division by Zero
 
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
> 
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list

http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121115/dcf511d2/attachment.html>


More information about the erlang-questions mailing list