title: c# float [] average loses accuracy
body: <p>I am trying to calculate average for an array of floats. I need to use indices because this is inside a binary search so the top and bottom will move. (Big picture we are trying to optimize a half range estimation so we don't have to re-create the array each pass).</p>
  
  <p>Anyway I wrote a custom average loop and I'm getting 2 places less accuracy than the c# Average() method</p>
  
  <pre><code>float test = input.Average();
  
  int count = (top - bottom) + 1;//number of elements in this iteration
  int pos = bottom;
  float average = 0f;//working average
  while (pos &lt;= top)
  {
       average += input[pos];
       pos++;
  }
  average = average / count;
  </code></pre>
  
  <p>example:</p>
  
  <pre>
  0.0371166766 - c#
  0.03711666 - my loop
  
  125090.148 - c#
  125090.281 - my loop </pre>
  
  <p><a href="http://pastebin.com/qRE3VrCt" rel="nofollow">http://pastebin.com/qRE3VrCt</a></p>