0
What NaN in java
When we divide float 0.0f with same 0.0f then the output is NaN. Why this NaN & what is the meaning of it? For example:- The output of below code is "Nan". Why this and so what is the meaning of NaN? float a=0.0f; float b=a; System.out.println(a/b); O/p: NaN
4 Respostas
+ 2
Not a Number, you try to divide 0/0 it is an "anomaly" in maths and leads to undefined behaviour. Computer cannot calculate this, so it outputs NaN
+ 1
But if both variables are int then it will throw an ArithmeticException but if anyone of both variables is float then it will print NaN.
Is there any reason, means anyone know it?
0
Thanks Jakub Stasiak...