In Java, what does NaN mean?

后端 未结 11 2263
时光说笑
时光说笑 2020-11-22 14:00

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

What does NaN mean in Java?<

相关标签:
11条回答
  • 2020-11-22 14:41

    NaN means "Not a number." It's a special floating point value that means that the result of an operation was not defined or not representable as a real number.

    See here for more explanation of this value.

    0 讨论(0)
  • 2020-11-22 14:41

    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

    Post your program here if you need more help.

    0 讨论(0)
  • 2020-11-22 14:42

    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.

    0 讨论(0)
  • 2020-11-22 14:46

    NaN means “Not a Number” and is basically a representation of a special floating point value in the IEE 754 floating point standard. NaN generally means that the value is something that cannot be expressed with a valid floating point number.

    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.

    0 讨论(0)
  • 2020-11-22 14:46

    Not a valid floating-point value (e.g. the result of division by zero)

    http://en.wikipedia.org/wiki/NaN

    0 讨论(0)
  • 2020-11-22 14:50

    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.

    0 讨论(0)
提交回复
热议问题