在 Java 中,NaN 是什么意思?

在 Java 中,NaN 是什么意思?

问题描述:

我有一个程序试图将 double 缩小到所需的数字.我得到的输出是 NaN.

I have a program that tries to shrink a double down to a desired number. The output I get is NaN.

NaN 在 Java 中是什么意思?

What does NaN mean in Java?

摘自 本页:

NaN"代表非数字".楠"如果浮点数产生操作有一些输入参数导致操作产生一些未定义的结果.例如,0.0 除以 0.0 在算术上是未定义的.取a的平方根负数也是未定义的.

"NaN" stands for "not a number". "Nan" is produced if a floating point operation has some input parameters that cause the operation to produce some undefined result. For example, 0.0 divided by 0.0 is arithmetically undefined. Taking the square root of a negative number is also undefined.