understanding floating point variables

Posted by Syom on Stack Overflow See other posts from Stack Overflow or by Syom
Published on 2010-03-19T21:30:21Z Indexed on 2010/03/19 21:41 UTC
Read the original article Hit count: 656

Filed under:
|

There is some problem, i can't understand anyway.

look at this code please


<script type="text/javascript">
function math(x)
{
 var y;
 y = x*10;
 alert(y);
}

</script>
<input type="button" onclick="math(0.011)">

What must be alerted after i click on button? i think 0.11, but no, it alerts 0.10999999999999999 explain please this behavior. thanks in advance

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about floating-point