title: Fixed-Point-Math - Is the conversion from float safe to always yield the same result?
body: <p>I'm using libfixmath for a simulation the needs to take place on two devices (iOS / Android) at the same time and be perfectly accurate.</p>
  
  <p>The simulation needs to be fed with some initial float parameters. I'm wondering, if it's safe to use floats and then convert them into fix16_t in the way below (the function is from the library) or if I need to feed the simulation with fix16_t values already?</p>
  
  <p>Hence, is it possible that two different devices calculate different results with the same input for the function below, because of floating point inaccuracy?    </p>
  
  <pre><code>typedef int32_t fix16_t;
  static const fix16_t fix16_one = 0x00010000; /*!&lt; fix16_t value of 1 */
  
  static inline fix16_t fix16_from_float(float a)
  {
      float temp = a * fix16_one; 
  
      // rounding
      temp += (temp &gt;= 0) ? 0.5f : -0.5f;
      return (fix16_t)temp;
  }
  </code></pre>