tags:

views:

591

answers:

11

I have a program that more or less tries to widdle a double down to a desired number. The output i get though, instead of being that final double is NaN

What does this mean?

A: 

Hey,

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.

Brian
A: 

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

Chris Thompson
A: 

NaN = Not a Number.

Mendy
A: 

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

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

Vladimir Dyuzhev
A: 

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).

sepp2k
+1  A: 

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.

Mike Daniels
+9  A: 

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.

KennyDeriemaeker
Additionally, NaN is defined by The IEEE Standard for Floating-Point Arithmetic (IEEE 754) quite explicitly which Java follows blindly. Reading the standard opens your eyes to a lot of things, the multiple values of zero being one of the things.
Esko
A: 

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: http://www.concentric.net/~Ttwang/tech/javafloat.htm

Post your program here if you need more help.

Prachi
+1  A: 

NaN means Not a Number and is basically a representation of a double value in IEE 754 floating point representation meaining that the data is actually not a number.

A conversion will result in this value, when unexpected the value cannot be converted (for example by converting a string that does not represent a number into a float).

poke
A: 

Means Not a Number. It is a common representation for an impossible numeric value in many programming languages.

LucaB
A: 

NaN means Not a Number, thus, the variable might not be set, or null (which is the same). Or you might have divided something by zero.

arik-so