在 Java 中,NaN 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2618059/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
In Java, what does NaN mean?
提问by David
I have a program that tries to shrink a double
down to a desired number. The output I get is NaN
.
我有一个程序试图将 adouble
缩小到所需的数字。我得到的输出是NaN
.
What does NaN
mean in Java?
NaN
在 Java中是什么意思?
采纳答案by KennyDeriemaeker
Taken from this page:
取自此页面:
"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.
“NaN”代表“非数字”。如果浮点运算具有一些导致运算产生某些未定义结果的输入参数,则会产生“Nan”。例如,0.0 除以 0.0 在算术上是未定义的。取负数的平方根也是未定义的。
回答by Brian Mains
Not a Java guy, but in JS and other languages I use it's "Not a Number", meaning some operation caused it to become not a valid number.
不是 Java 人,但在 JS 和其他语言中,我使用它是“非数字”,这意味着某些操作导致它成为无效数字。
回答by Chris Thompson
It literally means "Not a Number." I suspect something is wrong with your conversion process.
它的字面意思是“不是数字”。我怀疑您的转换过程有问题。
Check out the Not A Number section at this reference
查看此参考资料中的“非数字”部分
回答by Fitzchak Yitzchaki
NaN = Not a Number.
NaN = 不是数字。
回答by Vladimir Dyuzhev
Not a valid floating-point value (e.g. the result of division by zero)
不是有效的浮点值(例如除以零的结果)
回答by sepp2k
NaN
means "Not a Number" and is the result of undefined operations on floating point numbers like for example dividing zero by zero. (Note that while dividing a non-zero number by zero is also usually undefined in mathematics, it does not result in NaN but in positive or negative infinity).
NaN
表示“不是数字”,是对浮点数进行未定义运算的结果,例如将零除以零。(请注意,虽然非零数除以零在数学中通常也是未定义的,但它不会导致 NaN 而是正无穷大或负无穷大)。
回答by Mike Daniels
回答by Prachi
NaN stands for Not a Number. It is used to signify any value that is mathematically undefined. Like dividing 0.0 by 0.0. You can look here for more information: https://web.archive.org/web/20120819091816/http://www.concentric.net/~ttwang/tech/javafloat.htm
NaN 代表非数字。它用于表示任何数学上未定义的值。就像 0.0 除以 0.0。您可以在此处查看更多信息:https: //web.archive.org/web/20120819091816/http: //www.concentric.net/~ttwang/tech/javafloat.htm
Post your program here if you need more help.
如果您需要更多帮助,请在此处发布您的程序。
回答by poke
NaN
means “Not a Number”and is basically a representation of a special floating point value in the IEE 754 floating pointstandard. NaNgenerally means that the value is something that cannot be expressed with a valid floating point number.
NaN
表示“非数字”,基本上是IEE 754 浮点标准中特殊浮点值的表示。NaN通常意味着该值不能用有效的浮点数表示。
A conversion will result in this value, when the value being converted is something else, for example when converting a string that does not represent a number.
当被转换的值是其他值时,例如转换不代表数字的字符串时,转换将产生此值。
回答by lbedogni
Means Not a Number. It is a common representation for an impossible numeric value in many programming languages.
意味着不是数字。它是许多编程语言中不可能的数值的常见表示。