title: javascript strange rounding problem
body: <p>I have the following javascript function for rounding:</p>
  
  <pre><code>function round(val, numberdigits){
  
      return Math.round(val*Math.pow(10, numberdigits))/Math.pow(10, numberdigits);
  
  }
  </code></pre>
  
  <p>In most of the cases, it does its job well, but in some rare cases, the returned value has one digit more, which is always a 5.</p>
  
  <p>Example list of results with numberofdigits = 3:</p>
  
  <p>5.329 - 5.081 - 4.271 - 3.271 - 2.1525 - 2.1375 - 2.1225 - 1.997 - 2.044 - 2.031 - 2.028</p>
  
  <p>Can someone explain this? Or maybe provide me with a better rounding function which prevents this problem?</p>