Comparing computed floating point numbers for equality is almost always a bad idea, because (as others have argued) they are approximations and errors appear.
Instead of checking for a == b, check for equality within the threshold that makes sense for your application, as is the case with Math.abs (ab) <0.00001. This is good practice in any programming language that represents numbers as floating point values.
If you store integers in floating point variables and just add, subtract and multiply, they will remain integers (at least until they go beyond). But division, the use of trigger functions, etc., will lead to errors that must be resolved.
-m @
source share