I had a problem in some process in my web, after a time looking for a problem, I can detect what happened, now I had a question, why it is happening?.
Example: Below there is a code example:
function DoSomething(number, divisor){
var result = number % divisor;
var minimumAllowed = 0;
if(result == minimumAllowed){
.... Do stuff
}
}
When the code passes in the parameters, number = 1000 and divisor = 0.2, I could reproduce the problem.
Here is the problem in mozilla console:
1000 % .2 = 0.1999999999999445
1000 / .2 = 5000
I think 1000 % .2 = 0
, not 0.1999999999999445
so 1000 / .2 is 5000
.
Thanks alot for explainme.