JavaScript Bug?

Hello!

I am writing you for the very first time in my life. Today I came across something really weired in JavaScript, I would call it a bug and it's my request that please have a look at it.

Please run the following script in your browser and you will see what I mean.

<script type="text/javascript">
num=0.14;
num+=0.01;
alert(num);
</script>

Please don't say that rounding up will solve the problem. I know rounding up will solve the problem but the point is that there is something wrong. And it took hours to debug it because I really had no idea that there could have been such type of mistake/bug/issue in JavaScript. I was doing debugging somewhere else and the root cause was somewhere else. And the most interesting thing is that if you have num=0.13 and you add 0.01 to it, it will work fine. Problem occurs ONLY when you have num=0.14 and you add 0.01 to it.

It tested the above code on different machines (both Windows and Mac) and different browsers (Chrome, Firefox and Safari).

I've really no idea where to write and who to address therefore I'm sending an email to this address, kindly forward it to the concerned authorities.

-- 
regards,
K.A.Noorani

Received on Thursday, 5 May 2011 05:33:21 UTC