I've been coding in R for years and something really weird is just happening and is driving me crazy..
I have this simple loop:
st=0
for (i in 1:20){
if(st==0.3){print("Test passed")}
st=st+0.1
}
Somehow, no idea why, the condition st==0.3 never hits True, i can print st
at every step of the loop and it in facts becomes 0.3 at the proper step, but it's not triggering the condition. I've tried with other values and it seems to work, bun not with 0.3.
Now, this is just a "verification" example i made to test the problem, the original happened in another loop where a similar if is not getting triggered with many more values and i checked the variable takes those values at the corresponding steps and nothing.
I suspect, i don't know, maybe some kind of internal single precission is giving a slighty different number and is not being shown, or something like that.
Any idea what can be happening?