+ Reply to Thread
Results 1 to 6 of 6

Can anyone explain this to me please?

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    2

    Angry Can anyone explain this to me please?

    Hi,

    Can anyone explain this highly irritating issue please?

    I'm using the following formula:

    =IF(A146=0,0,E145+C146-D146)
    where E145 = -5089.22
    and C146 = 5089.22
    and D146 = 0
    which produces effectively -5089.22 + 5089.22 as shown below.
    Capture 1.JPG


    This then calculates at the next step as 1.8189E-12 rather than 0.
    Capture 2.JPG

    Yet when I do E145 + C146 it works out fine.

    Any ideas anyone please????!!!!

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Can anyone explain this to me please?

    Floating point arithmetic errors. Good explanation provided here: http://support.microsoft.com/kb/78113

    The ROUND function takes care of it most elegantly.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Can anyone explain this to me please?

    Your computer stores numbers in binary floating-point format. In the same sense that 1/3 is a repeating decimal in base 10, and so cannot be repeated exactly with any finite number of digits, many values (like 0.1) are repeating decimals in base 2.

    When testing equality, you need to include some rounding or a tolerance:

    =if(abs(...) < 1e-6, ..., ...)
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    01-20-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Can anyone explain this to me please?

    Thanks.

    Very irritating still.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Can anyone explain this to me please?

    It could not be any other way.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Can anyone explain this to me please?

    Please take a moment to read the forum rules and then amend your thread title to something descriptive of your problem. Once you have done this please send me a PM and I will remove this request.

    To change a Title on your post, click EDIT POST then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. [SOLVED] Please explain
    By Maxwell in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-31-2006, 08:15 AM
  2. Can Anyone Explain This?
    By Paul Smith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-06-2005, 04:05 PM
  3. [SOLVED] Let me see if I can explain this...
    By jsc3489 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 AM
  4. Let me see if I can explain this...
    By jsc3489 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  5. [SOLVED] Let me see if I can explain this...
    By jsc3489 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

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