# Certain values causing IF statement to perform incorrectly

1. ## Certain values causing IF statement to perform incorrectly

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.

2. ## Re: Certain values causing IF statement to perform incorrectly

strange that but
=IF((B1-A1)=INT(B1-A1),"true","false") seems to work

3. ## Re: Certain values causing IF statement to perform incorrectly

Might be a precision error..are you sure you have just the one decimal place?
http://www.cpearson.com/excel/rounding.htm

On a side note, the true and false in your formula are redundant

Just this should also give you true/false values
=B1-A1=INT(B1-A1)

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1