Created
July 10, 2014 10:50
-
-
Save cokeSchlumpf/670829810742c1dd1477 to your computer and use it in GitHub Desktop.
NaNTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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