title: TimeSpan Calculation Error
body: <p>I created a small piece of software in c# that calculates overtime in decimal format.  I have designed it so that it always rounds down to the nearest tenth of an hour.  The problem that I am having is that when I try to calculate a time that is exactly 2 hours 12 minutes or 3 hours 12 minutes I get an incorrect result.  The relevant code follows:</p>
  
  <pre><code>   DateTime start = new DateTime(
                          dtpDateStart.Value.Year,
                          dtpDateStart.Value.Month,
                          dtpDateStart.Value.Day,
                          dtpTimeStart.Value.Hour,
                          dtpTimeStart.Value.Minute,
                          0);
  
          DateTime end = new DateTime(
              dtpDateEnd.Value.Year,
              dtpDateEnd.Value.Month,
              dtpDateEnd.Value.Day,
              dtpTimeEnd.Value.Hour,
              dtpTimeEnd.Value.Minute,
              0);
  
          TimeSpan subtotal = end - start;
  
          double subtotalRounded = subtotal.TotalHours;
          subtotalRounded = (Math.Floor(subtotalRounded * 10) / 10);
  </code></pre>
  
  <p><code>dtpDateStart</code>, <code>dtpTimeStart</code>, <code>dtpDateEnd</code> and <code>dtpTimeEnd</code> are all date time picker controls in a Win Forms project.</p>
  
  <p>When I debug this code I find that the returned value of <code>subtotalRounded</code> is either 2.1999999999999997 or 3.1999999999999997 instead of 2.2 and 3.2. This doesn't seem to happen with values of 4 hours 12 minutes or greater or 1 hour 12 minutes or less.</p>
  
  <p>Anyways, I'm completely stumped why rounding error occurs with only these two values. Does anyone have any suggestions or comments?  Am I using the method incorrectly or is there a better way to do this?</p>