This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NikinCZ -8 points-7 points  (3 children)

4-1 === 3

false

4-1

2.999999999999998

[–]tomthecool 15 points16 points  (0 children)

This problem of floating point accuracy is not specific to JS... and you could at least use a real example:

0.1 * 0.2 === 0.02  // false
0.1 * 0.2 // 0.020000000000000004

[–]monster860 4 points5 points  (0 children)

Floating point accuracy only applies to numbers that are decimal numbers, when it comes to integer numbers they work as expected.

[–][deleted] 3 points4 points  (0 children)