blog’s amazing Rotating Header Image

Posts from ‘March, 2009’

Are there problems with floating point in JavaScript?

JavaScript is a mature language (holding mature issues), though tomorrow I’ve ran into something that’s out of this world:
<script type=”text/javascript”>
document.write( 0.1 + 0.2 );
document.write( ‘<br />’ );
document.write( 0.1 + 0.2 === 0.3 );
</script>
Guess what?
0.30000000000000004
false
Well, not exactly the result I’ve expected.
However, the issue is absolutely not unknown neither new: many languages (including C) have similar issues [...]