title: Double precision?
body: <p>I have a situation where I'm sending a number to a method, it divides that number into 6 and returns a List with the number 6 divided by n number of items. I'm pulling the dividing number from a dictionary.count and combining the returning list with the dictionary I pulled it from. Returned list, For some reason it does not always return the correct number of items. It works fine through 12. But then it's predictable, if not reliable. The following numbers return a list with 1 less index than is needed...13,15,18,23,25,20,27,28,30.....The code below was pulled from a larger project.</p>
  
  <pre><code>public void DivTest()
  {
      double value;
      Double.TryParse(textBox1.Text, out value);
  
      double div = 6 / value;
      int count = 1;
  
      StringBuilder sb = new StringBuilder();
  
      for (double d = div; d &lt;= 6; d += div)
      {
          sb.Append(count.ToString()).Append("  :  ")
              .Append(d.ToString("0.0000")).Append("  :  ")                                                                                                                             
              .Append(div.ToString("0.0000")).AppendLine();
  
          count++;
      }
  
      label1.Text = sb.ToString();
  }
  </code></pre>
  
  <p>If you add this code to a form with a default named textbox, label and button, it probably won't work correctly with you either. The last line should always be 6, but it's with the numbers I've mentioned. I thought it was a rounding issue, but I'm not using rounding in this example. Any ideas? Thanks.</p>