C++ (int) static cast weird error
<p>I have a very weird error with c++.
I have two values, max and singleStep. The number of steps is stepsInt and/or stepsDbl:</p>

<pre><code>max = 100;
singleStep = 0.1;
// This means that I have 100/0.1 = 1000 numbers betwwen 0 and 100
double stepsDbl = max/singleStep;
int stepsInt = (int)(stepsDbl);
cout &lt;&lt; stepsDbl &lt;&lt; stepsInt;
</code></pre>

<p>You can expect an output like this:</p>

<pre><code>1000 1000
</code></pre>

<p>However I'm getting this output:</p>

<pre><code>1000 999
</code></pre>

<p>What is more, if I try a different value for singleStep, for instance 0.2, I get again wrong values</p>

<pre><code>500 499
</code></pre>

<p>I don't know what is happening but is pretty weird... If anyone has a solution for this problem I would appreciate that solution. </p>

<p>Thanks</p>
