JavaScript - Unexpected Results
<p>I'm trying to create an step by step calculation effect for by using js, which subtracts, divides and multiplies the numbers, it works fine, but sometimes and only sometimes gives unexpected results: like <code>18001</code> or '17998', here is a part of the script:</p>

<p>supposing values are: </p>

<pre><code>var neu = 18000;
var old = 40000;

    if (neu &gt; old) {
    step = parseInt((neu - old) / 5);
    increase(old, step, neu);  
   }

    if (old &gt; neu) {
    step = parseInt((old - neu) / 5);
    decrease(old, step, neu);
   }

function decrease(old, step, neu) {
    var i = 0 ;
    function countDown() {
     if (i &lt; 5) {
       old -= step;
       $("#total-price-value").text(old); 
       i++;
       delay1 = setInterval(countDown, 80);

    } else {
      clearInterval(delay1);
    }
}
   countDown();

} // increase looks like this
</code></pre>

<p>all of the numbers are like: 18000, 10000, 300000, and so on, i can't find a culprit, what makes the number different? </p>

<p>if a value is <code>187999</code> or <code>188001</code> how can detect and make it <code>188000</code>? i have tried <code>Math.round</code> and other <code>Math</code> object methods but with no avail. </p>
