Skip to content

Instantly share code, notes, and snippets.

@cokeSchlumpf
Created July 10, 2014 10:50
Show Gist options
  • Select an option

  • Save cokeSchlumpf/670829810742c1dd1477 to your computer and use it in GitHub Desktop.

Select an option

Save cokeSchlumpf/670829810742c1dd1477 to your computer and use it in GitHub Desktop.
NaNTest
public class NaNTest {
public static void main(String[] args) {
double a = 10.0 / 0.0;
double b = a * 3;
System.out.println(a);
System.out.println(b);
checkValue(b);
}
public static void checkValue(double val) throws ArithmeticException {
if (Double.isInfinite(val) || Double.isNaN(val))
throw new ArithmeticException("illegal double value: " + val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment