console.log(308.22 + 297.93);
In chrome console output is 606.1500000000001 but it should be 606.15. Why?
console.log(308.22 + 297.93);
In chrome console output is 606.1500000000001 but it should be 606.15. Why?
Real numbers can not be represented in javascript (and other languages which use a floating-point type) accurately.
They are just an approximation. See floating point for more information.
It is called rounding error - http://en.wikipedia.org/wiki/Round-off_error
It is down to how computers store floating point numbers.
That is why it is also tricky for comparisons.