title: C# Math.Floor double with no decimal places gets rounded down. Sometimes
body: <p>I'm using Math.Floor to round a double down to no decimals.
  This is working as expected, apart from some cases.
  Sometimes, when the double doesn't have any decimal places, Math.Floor lowers the double by 1. So 2006 becomes 2005 for example. This doens't always happen, most of the times it doesn't change the value of the double. 2005 stays 2005.</p>
  <p>Code snippet:</p>
  <pre><code>double dBuislengte = 0;
  dBuislengte = swDispDim.GetDimension2(0).Value;
  Debug.Print(&quot;d: &quot; + dBuislengte);
  dBuislengte = Math.Floor(dBuislengte);
  Debug.Print(&quot;d Math.Floor: &quot; + dBuislengte);
  </code></pre>
  <p>Output:</p>
  <pre><code>d: 436
  d Math.Floor: 436
  d: 1854,5
  d Math.Floor: 1854
  d: 1951,5
  d Math.Floor: 1951
  d: 2006
  d Math.Floor: 2005
  </code></pre>
  <p>As you can see, the first output value is what I expect to happen and what happens most of the time. The last value shows the problem.</p>
  <p>I can fix it by only do the Math.Floor operation on doubles with decimal places, but that won't help me understand what's going on.
  Can someone point me in the right direction?</p>
  <p>Thanks!</p>