I'm getting a strange behavior in an IF statement in Excel.
I'm trying to subtract two numbers, and have the IF statement tell if the result if an integer or not. So I'm using this statement:
=IF((B1-A1)-INT(B1-A1)=0,"true","false")
Now, most of the time this works. For example, if A1=6.1 and B1=12.8, the difference is 6.7, not an integer, and it comes up as False.
Similarly, if A1=6.1 and B1=12.1, the difference is 6, and the answer comes up as True.
HOWEVER
If A1=6.2 and B1=12.2, the difference is still 6, but the answer comes up as False. The same thing happens with 6.3 and 12.3. It only happens for those two decimals, and it only happens for integer answers from 2 to 7. (So 6.3 and 7.3 works, but 6.3 and 8.3 doesn't. 6.3 and 13.3 doesn't, but 6.3 and 14.3 does.)
What's going on here?
I also tried to use the ROUNDDOWN function instead, and replaced the INT(B1-A1) portion with ROUNDDOWN(B1-A1,0), and I get the exact same behavior. I've verified the behavior on two separate machines as well.
Bookmarks