none
JavaScript Error RRS feed

  • Question

  • I just found a calculation error for JavaScript. I don't know if anyone knows this already?

    when use 8.2, 8.8 and 8.9 divided by 100, you will get 0.08199999999999999, 0.088000000000001 and 0.08900000000000001

    I have test on both IE 6 and Firefox 2.0.0.1

    <html>
    <head>
    <script language="JavaScript">
    function fo()
    {
     var n1,n2,n3;
     n1 = 8.2;
     n2 = 8.8;
      n3 = 8.9;
     alert(n1/100);
      alert(n2/100);
     alert(n3/100);
    }
    </script>
    </head>
    <body>
    <input type="button" id="b1" value="go" onclick="return fo();">
    </body>
    </html>

    Tuesday, March 20, 2007 5:16 PM