+ Reply to Thread
Results 1 to 8 of 8

=if rounding issue

  1. #1
    Registered User
    Join Date
    07-28-2014
    Location
    UK
    MS-Off Ver
    Excel Mac 2008
    Posts
    3

    =if rounding issue

    Hi,

    My problem concerns rounding (I think!).

    I am using the following =if formula:

    =IF(BA127>=AU127,AU127,AU127-BA127)

    The cells show both BA127 & AU127 as equalling 8.0, therefore I would expect the formula to return a value of 8.0. It is in fact calculating (or not) as 6.03961E-14. I have increased the decimal points on both cells and it still presents as 8.0, however when I copy & value BA127 it does so as 7.9999999888.

    Is there a way I can work around this inequality i.e. by putting in an error factor of say +/- 0.001?

    Many thanks in advance.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,518

    Re: =if rounding issue

    What I expect you are looking at is normal round off error caused by the way computers do arithmetic.

    If 0.001 is the desired "error" tolerance, probably should be something like if(ba127>=au127-0.001,au127,au127-ba127). You have to really decide if 0.001 is the correct tolerance (would you really want 7.9991 to be considered >= 8.0000?).
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    07-28-2014
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: =if rounding issue

    Why not combine with ROUND

    =IF(ROUND(BA127,4)>=ROUND(AU127,4),AU127,AU127-BA127)

  4. #4
    Registered User
    Join Date
    07-28-2014
    Location
    UK
    MS-Off Ver
    Excel Mac 2008
    Posts
    3

    Re: =if rounding issue

    Many Thanks Alex,

    It worked, but due to the iterative nature of this part of my spreadsheet it has moved the problem into the next cell........

    I have used the formula: =IF(AS127-AX127-AY127<AS127,AS127-AX127-AY127,AS127) where AS127 is now 15.99999999999 AX127 is 8.0000000 and AY127 also = 8.00000000. I have tried to use your rationale for rounding, but to no avail. I would expect the answer to be 0.

    I hope you can assist.

    Thanks.

  5. #5
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: =if rounding issue

    Quote Originally Posted by the running frog View Post
    The cells show both BA127 & AU127 as equalling 8.0, therefore I would expect the formula to return a value of 8.0.
    How are BA127 and AU127 found? Like, from some other formula?

    It kinda sounds to me like you're getting the problem upstream of the IF formula.

    Like, if BA127 is "7.9999999888"and then it's going off with an infinite number of trailing eights, then it will always display as "8.0" for however many arbitrary number of decimal points you display to, but it's not actually exactly 8.

    Also if AU127 = 8.0 (exactly),
    then I would expect the difference to be 1.12E-08, which is approximately 200,000 bigger than the 6E-14 value you're getting. (But that AU127 might be deceptively displaying as 8.0000 if all the trailing digits are greater than 5!)

    So I don't think either of your AU127 or BA127 values are exactly 8.0 there.

    This might be a computer arithmatic error, but I suspect you've got more going on than just that.

  6. #6
    Registered User
    Join Date
    07-28-2014
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: =if rounding issue

    Two options:

    1) presumably AS, AY, BA etc all contain formulae. If so encapsulate all these formulae with ROUND(...,3)
    2) encapsulate the logical tests in your IF formulae with ROUND(...,3)

    For example: =if(round(logical test,3)<round(logical test 2,3),do this if true,do this if false)

    Let me know how you get on

  7. #7
    Registered User
    Join Date
    07-28-2014
    Location
    UK
    MS-Off Ver
    Excel Mac 2008
    Posts
    3

    Re: =if rounding issue

    Many thanks Alex,

    It worked!

    Love learning new things.

    Neil
    the running frog
    [I]transforming performance[/I]

  8. #8
    Registered User
    Join Date
    07-28-2014
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: =if rounding issue

    Always a pleasure

+ 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. Rounding issue
    By boyaco in forum Excel General
    Replies: 6
    Last Post: 12-17-2009, 09:29 PM
  2. Rounding Issue
    By alex57 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-08-2008, 09:54 AM
  3. [SOLVED] Another rounding issue
    By Biff in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2005, 09:05 AM

Bookmarks

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