x86 indicates a special type of QNaN, the so-called undefined QNaN undefined (section 4.8.3.7 in IA32 Manual ):
For encodings of the floating point data type (single-precision, double precision, and double extended precision), one unique encoding (QNaN) is reserved to represent the undefined floating point QNaN special value. X87 FPUs and SSE / SSE2 / SSE3 / SSE4.1 / AVX Extensions return these undefined values ββas responses to some masked floating point exceptions. Table 4-3 shows the encoding used for the QNaN undefined floating point.
This is what prints as -1.#IND according to your C library implementation.
In your case, operation 0/0 triggers a masked Invalid Operation Exception on the FPU, which is signaled by an undefined return value. In the case of -(0/0) you supply this undefined value as input to the negation operation, which returns QNaN.
The reason that different floating point operations give different error values ββmakes debugging easier. An experienced developer can more easily track an error if she knows exactly what NaN value is returned. For non-debugging purposes, since undefined is just a special kind of QNaN, you can often ignore the difference at all.
source share