Why do integers not represent Nan in Java?

When I write something like

double a = 0.0;
double b = 0.0;
double c = a/b;

The result is double Nan, but when I try the same for integers, it will produce arithmeticexception So, why not integer NaN?

Solution

The answer has little to do with Java Infinite or undefined numbers are not part of the integer set, so they are excluded from integer, while floating-point types represent real and complex numbers, so Nan has been included in floating-point types to deal with these

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>