title: SSE rounding precision
body: <p>I have a small problem with SSE rounding. The code is self explanatory, I am trying to get the count of 0.0001s in 293.05694580 including some rounding (e.g. there are 52 0.1s in 5.21)...</p>
  
  <pre><code>#include &lt;xmmintrin.h&gt; 
  #include &lt;emmintrin.h&gt; 
  
  int main(void)
  {
      float val       = (float) 293.05694580;
      float tickSize  = (float)   0.0001;
  
      __m128 _val     = _mm_set_ps1( val );
      __m128 _shift   = _mm_set_ps1( 1 / tickSize );
  
      /* 293.0569480 * 10000 should be 2930569.480 */
      __m128 _mul     = _mm_mul_ps(_val, _shift);
  
      /* Rounding 2930569.480 should get 2930569, but returns 2930570 instead. Why? */
      __m128i _ticks  = _mm_cvtps_epi32( _mul );
  }
  </code></pre>
  
  <p>Lastly, how can I revert the ordering of results in _ticks? 
  Many thanks, 
  Daniel</p>