title: 0.0 / 0.0 = -NAN?
body: <p>When exception masks are all enabled to stop the processor from throwing floating point exceptions the following calculation produces a somewhat strange result:</p>
  <p>0.0 / 0.0 = -nan</p>
  <p>(At least in Delphi).</p>
  <p>For now I will assume this is the case in C/C++ as well and with that I mean on x86/x64 which should and seems to be following IEEE 754 floating-point format.</p>
  <p>I am a little bit surprised by this and I want/need to know more. Where is this defined that 0.0 / 0.0 should be -NAN ?!?</p>
  <p>Problem is with the code, example:</p>
  <pre><code>T := 0;
  D := 0.0 / 0.0;
  P := T * D;
  </code></pre>
  <p>This screws up P. instead of P being zero, P is now also -NAN ?!?</p>
  <p>I find this very strange but ok.</p>
  <p>I guess a simple solution could be to set D to 0 explicitly for this case, is there perhaps another solution ? Maybe some kind of mask or rounding mode so that additional branch is not necessary ???</p>
  <p>In delphi it even depends on the platform.</p>
  <p>Win32: 0.0 / 0.0 = -NAN
  Win64: 0.0 / 0.0 = -1, #IND</p>
  <p>Win32 sets FPU exception mask
  Win64 sets SSE exception mask</p>
  <p>(I believe I read somewhere that there are slight differences in FPU vs SSE floating point operations, but can't recall right now... something to maybe further look into... for now my tests have shown that the code I am working on currently works on both platforms...)</p>
  <p>Just to be clear 0.0 for me at least simply means a 0 floating point number.</p>
  <p>Though there is also +0.0 and -0.0 I think... and also -Infinity and +Infinity.</p>
  <p>I would like to find some kind of specification or definition that goes deeper/explains why 0/0 produces these values ?!</p>
  <p>Also these values seem to be &quot;infectious&quot; like a virus lol, it seems to be &quot;propagated&quot; through operations, so far multiplication, addition and comparison have been observed/witnessed ! ;)</p>
  <p>P.S.: Keep your floating point issues out of my computer programs ! =D (Will SmITH meme =D)</p>