Special Values

Posted by Beetle B. on Thu 07 February 2019

NaN Signaling NaNs do not appear as the result of arithmetic operations. When they appear as an operand, they signal an invalid exception.

Quiet NaNs propagate through almost all operations without signaling exceptions. They are useful for debugging. Whenever a floating point operation is invalid, a quiet NaN is returned.

I didn’t quite follow this section! For example, why is \(\min(1,\mathrm{qNaN})\)?

Arithmetic of Infinities and Zeros

  • \((-1/-0)=\infty\)
  • \(-5/\infty=-0\)
  • \(\sqrt{\infty}=\infty\)

Here’s a gotcha. Suppose you are trying to calculate:

\begin{equation*} \frac{x}{\sqrt{1+x^{2}}} \end{equation*}

with \(x\in(\sqrt{\Omega},\Omega]\). The denominator will be \(\infty\) in round to nearest, and the result will be 0. But the actual correct result is very close to 1.

So one needs to check if an overflow occurred.