Input field values not adding up correctly
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/588004/is-javascripts-math-broken">Is JavaScript&#39;s Math broken?</a>  </p>
</blockquote>



<p>I'm attempting to add up three input fields, each containing a value of 33.3 which should total 99.9, however they are totaling to 99.89999999999999</p>

<p>Could someone explain how this is happening. Below is my code. Thanks in advance. </p>

<pre><code>$("#modify-funding input.percentCalc").sumValues()

$.fn.sumValues = function () {
    var sum = 0;
    this.each(function () {
        sum += $(this).fieldVal();
    });
    return sum;
};

$.fn.fieldVal = function () {
    var val;
    if ($(this).is(':input')) {
        val = $(this).val();
        alert("val " + val);
    } else {
        val = $(this).text();
    }       
    return parseFloat(('0' + val).replace(/[^0-9-\.]/g, ''), 10);
};
</code></pre>
