RosettaCodeData/Task/Detect-division-by-zero/Java/detect-division-by-zero-2.java

7 lines
220 B
Java
Raw Permalink Normal View History

2013-04-10 12:38:42 -07:00
public static boolean except(double numer, double denom){
try{
int dummy = (int)numer / (int)denom;//ArithmeticException is only thrown from integer math
return false;
}catch(ArithmeticException e){return true;}
}