+ Reply to Thread
Results 1 to 3 of 3

Certain values causing IF statement to perform incorrectly

  1. #1
    Registered User
    Join Date
    Washington, DC
    MS-Off Ver
    Excel 2010

    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:


    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.


    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. #2
    Forum Guru martindwilson's Avatar
    Join Date
    MS-Off Ver
    office 97 ,2007

    Re: Certain values causing IF statement to perform incorrectly

    strange that but
    =IF((B1-A1)=INT(B1-A1),"true","false") seems to work
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Guru Ace_XL's Avatar
    Join Date
    MS-Off Ver

    Re: Certain values causing IF statement to perform incorrectly

    Might be a precision error..are you sure you have just the one decimal place?

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

    Just this should also give you true/false values
    Life's a spreadsheet, Excel!
    Say thanks, Click *

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. If statement reading incorrectly
    By LifeMeansChange in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-01-2013, 09:56 AM
  2. perform:IF statement
    By MAHMUZ in forum Excel General
    Replies: 2
    Last Post: 04-04-2010, 08:19 AM
  3. If then statement causing value issues in Macros
    By ssciarrino in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2005, 02:10 PM
  4. INSERT INTO sql statement causing error
    By Michael Malinsky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2005, 04:05 PM
  5. [SOLVED] Excel displaying values incorrectly
    By Shaun in forum Excel General
    Replies: 3
    Last Post: 05-11-2005, 09:06 AM


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