avoiding error when dividing by 0
Posted: Tue Jan 20, 2009 8:06 am
Hi there,
I have some coding that divides a value (p) by a counting variable (q), i.e., "divide p by q". Sometimes when the user doesnt click on a certain button that they are meant to, the counting variable is still at zero when the command runs and therefore I get an error because I am trying to divide by zero.
Is there some sort of quick trick I can do that automatically returns a value of zero whenever I try to divide by zero? If there isnt, I guess I will have to create some kind of if...then... command that checks that the counting variable is not at zero.
Cheers,
Ac
I have some coding that divides a value (p) by a counting variable (q), i.e., "divide p by q". Sometimes when the user doesnt click on a certain button that they are meant to, the counting variable is still at zero when the command runs and therefore I get an error because I am trying to divide by zero.
Is there some sort of quick trick I can do that automatically returns a value of zero whenever I try to divide by zero? If there isnt, I guess I will have to create some kind of if...then... command that checks that the counting variable is not at zero.
Cheers,
Ac