I’m wondering about the accuracy of parseFloat.
Why? Because I am trying to add dollars together taken from string and there are inconsistencies.
The following is an example adding 114.97 and 69.99:
<html>
<body>
<script type=”text/javascript”>
document.write(“parseFloat(‘114.97’)=”+parseFloat(‘114.97’)+”<br />”);
document.write(“parseFloat(‘69.99’)=”+parseFloat(‘69.99’)+”<br />”);
document.write(“parseFloat(‘114.97’) + parseFloat(69.99)=”+(parseFloat(‘114.97’)+parseFloat(‘69.99’))+”<br />”);
</script>
</body>
</html>
===============================
parseFloat(‘114.97’)=114.97
parseFloat(‘69.99’)=69.99
parseFloat(‘114.97’) + parseFloat(69.99)=184.95999999999998
Can someone explain to me the above result?
Thanks…