Why -nan values appear
-
I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values
Because the math operations performed by your code result in a NaN? You cast an integer with at least the relevant most signficant bits set to
float
ordouble
? You have a buffer overflow writing such a value to the memory of afloat
ordouble
? Without seeing code, we can't tell you for sure. -
I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values
-
I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values
Because what ever you are doing, the result is not a number.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values
-
2 most likely reasons: Invalid math e.g. division by zero, or use of uninitialized variables. Without seeing your code, and input, we can't know.
ahem... Division by zero in general produces a (signed)
Inf
, not aNaN
.Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012