0

I'm using Google Chrome.

<html>
    <head>
        <script>
            function DoThis()
            {
                var value = 1.005;
                var multiplied = value * 100;
                alert(multiplied);
            }
        </script>
    </head>
    <body onload="DoThis();">

    </body>
</html>

multiplied ends up coming out as 100.49999999 instead of 100.5

Anyone have an explanation?

James
  • 680
  • 2
  • 8
  • 22

1 Answers1

0

All numbers in Javascript are stored as floats. You're seeing one of the limittions of float arithmetic.