What decides Nan and Infinity in java division operations
问题 Output of the below code confusing me. Why NaN sometimes and Infinity other times ? public static void main (String[] args) { double a = 0.0; double b = 1.0; int c = 0; System.out.println(a/0.0); System.out.println(a/0); System.out.println(b/0.0); System.out.println(b/0); System.out.println(c/0.0); System.out.println(c/0); } Outputs is: NaN NaN Infinity Infinity NaN Exception in thread "main" java.lang.ArithmeticException: / by zero What is the deciding factor here ? 回答1: This is because of