Why such different answers on dividing a number by zero:
My code:
class Test {
public static void main(String[] args){
int a = (int)(3/0.0F);
System.out.println(a);
System.out.println(3/0.0F);
System.out.println(3/0);
}
}
Output:
2147483647
Infinity
Exception in thread "main" java.lang.ArithmeticException: / by zero
Every time I divide a number by an integer (byte, short, int, long) it throws ArithmeticException, which is not the case when done with real numbers (float, double). Why?