+ Reply to Thread
Results 1 to 13 of 13

Calculation Error

  1. #1
    Registered User
    Join Date
    03-12-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    8

    Calculation Error

    The following cells have the following values in EXCEL 2007

    A1: 192.32
    B2: 16.28
    C2: 93.04

    The formula A1-B1-C1=0 returns FALSE
    The formula A1=(B1+C1) returns TRUE

    What!?!?!

    Further...
    $A$1-B$1-$C$1>-0.0000000000001 returns TRUE
    But..
    $A$1-B$1-$C$1>-0.00000000000001 returns FALSE

    Like I said... WHAT?!?!?!

    Finally...
    if you put the formula =A1-B1-C1 in cell D1, then the value is shown as 0 and the formula D1=0 returns TRUE

    I have reproduced this on three computers, on freshly minted spreadsheets - definitely something weird going on. Can anyone else reproduce or explain this. I haven't found any other combination of numbers that does this

    Thanks.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,465

    Re: Calculation Error

    Firstly, you refer initially to A1, B2 and C2 but your formulae refer to A1, B1 and C1

    But, 16.28 + 93.04 = 109.32 not 192.32

    Regards
    Last edited by TMS; 03-12-2011 at 06:23 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Calculation Error

    Assuming you meant B1 and C1 instead of B2 and C2, using your numbers and formulas in the cells you specified I get:

    =A1-B1-C1=0 returns FALSE
    =A1=(B1+C1) returns FALSE

    =$A$1-B$1-$C$1>-0.0000000000001 returns TRUE
    =$A$1-B$1-$C$1>-0.00000000000001 returns TRUE

    and finally, in D1
    =A1-B1-C1 gives correct result of 83 - not 0
    so, of course, =D1=0 returns FALSE

    All results are correct.

  4. #4
    Registered User
    Join Date
    03-12-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculation Error

    Quote Originally Posted by TMShucks View Post
    Firstly, you refer initially to A1, B2 and C2 but your formulae refer to A1, B1 and C1

    But, 16.28 + 93.04 = 109.32 not 192.32

    Regards
    Quite right. I meant 109.32. Try it...

  5. #5
    Registered User
    Join Date
    03-12-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculation Error

    Have a look at this: http://www.airplaystudios.co.uk/book2.xlsx
    cells D1 and E2 are doing the same thing but get different results,

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Calculation Error

    Well now I see the "WHAT?!?!?!"

    To further point out the inconsistency try this:

    In your formula =A1-B1-C1=0 (which returns FALSE) highlight the A1-B1-C1 portion in the formula bar. Hit F9 and it calculates to 0 so you have =0=0. Hit enter and you get TRUE!
    Hit Undo to return formula to its original form and you get FALSE.

    I'm sure the wise ones can explain it. I can't.

  7. #7
    Registered User
    Join Date
    03-12-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculation Error

    Thanks for checking. At least I know I'm not going mad! As I said, if you change the numbers (to ones that add up), it operates as expected. change them back and it's all wrong again...

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Calculation Error

    No, you're not going mad. I recreated it on a new spreadsheet.

    I have asked for some input from the Excel gurus on this thread so expect something soon.

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Calculation Error

    A couple of other head scratchers:

    =SUM(B1:C1)=A1 is TRUE but =A1-SUM(B1:C1)=0 is FALSE

    and

    =B1+C1=A1 is TRUE but =A1-(B1+C1)=0 is FALSE

  10. #10
    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: Calculation Error

    Excel uses your computer's IEEE 754 binary floating-point representation of numbers, which cannot precisely represent decimal numbers like 0.1 (and many others). In binary, they are repeating decimals, just like 1/3 is in base 10.

    When comparing floating-point numbers, you should always include an epsilon, e.g.,

    =if(abs(a1/b1 - 1)<1e-14, "they're more or less equal", "they're not")
    Entia non sunt multiplicanda sine necessitate

  11. #11
    Registered User
    Join Date
    03-12-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculation Error

    I think I'll just use ROUND() - these numbers represent money, so 14 decimal places aren't necessary. I'm amazed that this sort of issue can arise at two decimal places - very disappointing.

  12. #12
    Registered User
    Join Date
    03-12-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Calculation Error

    In case anyone is still reading this... OpenOffice copes with this perfectly

  13. #13
    Valued Forum Contributor jwright650's Avatar
    Join Date
    12-10-2010
    Location
    Va, USA
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    606

    Re: Calculation Error

    I found some division querks in Excel when helping my kids with their homework, probably the same type of deal where the decimal is acting up...weird stuff, and sometimes when you least expect it.
    Life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
    John Wright

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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