title: Objective C - divide long by a float without losing precision
body: <p>I'm having precision problems when dividing an long type with a float and ended up messing the calculations in the app. Let say I'm just converting a millisecond to second, since that is a requirement on our end. Below is a sample test case</p>
  
  <pre><code>long startTimeMS = 2529095;
  NSTimeInterval expectedStartTime = 2529.095
  NSTimeInterval startTime = startTimeMS / 1000.f; //Results to "2529.09497"
  double startTimeDouble = startTimeMS / 1000.0 // Results to "2529.0949999999998"
  
  XTCAssert(startTime == expectedStartTime, @"Invalid start time")
  </code></pre>
  
  <p>Upon dividing a long by float, it loses precision by a 3 thousandth. Similar with long divided by double. </p>
  
  <p>How do I make it so that dividing it would come out the same as the expected start time? I'm guessing rounding up to nearest thousandth in decimal would also be good but the rounding methods I found here isn't reliable either like this</p>
  
  <pre><code>float roundToTwo(float num)
  {
      return round(100 * num) / 100;
  }
  </code></pre>
  
  <p>Which most likely return the same value</p>