1

Possible Duplicate:
Is JavaScript's Math broken?
Elegant workaround for JavaScript floating point number problem

when i run following code

<html>
<head>
<script type="text/javascript">
var  a=0.1;
var b=0.2;
var c=0.3;
document.write((a+b)+c);
document.write(' ');
document.write(a+(b+c));
document.write('  ');
document.write(a+b);
</script>
</head>
<body>

</body>
</html> 

it shows me follwoing result

0.6000000000000001 0.6 0.30000000000000004 

i dont understand how a+b=0.30000000000000004 also 0.30000000000000004+0.3 how is equal to 0.6?

Community
  • 1
  • 1

0 Answers0