Question

In specific:

Im doing some math operations, and the application keeps crashing because a double that is widely used happens to get the value: -1.#IND000000000000 when "some" numbers are sqrt'ed... What is this? Indefinite? Infinite? Too big to fit? Not a perfect Square Root? Is there any way to solve this? Thanks in advance! EDIT: How can i check if a double has this value ? I tried: if (x == 0x-1.#IND000000000000) and other variations but did not work. Is it possible to check to see if a variable has this value ?

Was it helpful?

Solution

Actually, the string -1.#IND000000000000 is not a value, returned by a function, but it is one of a common representations of a QNaN, Quiet Not-a-Number, the special IEEE-754 value representing the invalid number, that won't cause the exception (there are also SNaN, Signalling NaN, which would cause the floating point exception, if enabled). The common cause of this is calling a function with argument out of it's domain.

OTHER TIPS

NaNs (such as the "indeterminate" you have and "infinity") can be detected by checking x == x (it's false for NaN and true for any finite number).

The value #IND000000000000 represents an invalid numeric value. This is often called a QNaN (Quiet Not-A-Number) value because it represents an indeterminate type but does not cause calculations to fail.

Chances are, the elusive numbers whose square root you're attempting to determine are negative numbers, for which that value is not defined. See Wikipedia for more information.

Solving it will first require you to determine where the problem is occurring. That means you either need to step through yourself it with a debugger and watch the values of the variables, or post your code so that we can do the same.

If the argument is negative, a domain error occurs, setting the global variable errno to the value EDOM.

Without using a complex type, sqrt of any value below 0 is meant to cause an exception.

It's a NaN (Not A Number). It means you've called sqrt with a negative argument.

Cheers & hth.,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top