Search code examples
c++sqrt

C++ sqrt returns -1.#IND000000000000


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 ?


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.