title: Java, addition error
body: <p>I noticed two days ago I had some weird strange issue with my lib transforming a mat4 (matrix 4x4, row major order) to a quat (quaternion) when I had 180° on z axes and 1° on x, all other values work just fine, that is 180° and 2° or 179° and 1° and so on..</p>
  
  <p>After some deep debug, I found the issue</p>
  
  <pre><code>    double trace = 0, s, x, y, z, w;
  
      trace = m.c0.x + m.c1.y + m.c2.z + 1;
  </code></pre>
  
  <p>This should return trace = 0, given</p>
  
  <pre><code>m.c0.x -1.0
  m.c1.y -0.9998477
  m.c2.z 0.9998477
  trace 5.9604644775390625E-8
  </code></pre>
  
  <p>But it doesn't... Why?</p>
  
  <p>I found a temporary solution by calculating trace as the following:</p>
  
  <pre><code>    trace += m.c0.x;
      trace += m.c1.y;
      trace += m.c2.z;
      trace += 1;
  </code></pre>
  
  <p>Anyway I would like to know the reason in order to act accordingly in the future</p>
  
  <p>Ps: I tried to convert it to double, they were floats before, but nothing changed. <a href="https://github.com/elect86/Jglm/blob/master/Jglm/src/jglm/Quat.java" rel="nofollow">Here</a> the full code</p>
  
  <p>Specs: Java 7 x64 on Win7 x64.</p>