+ Reply to Thread
Results 1 to 12 of 12

Arithmetic Inconsistencies

  1. #1
    Registered User
    Join Date
    01-04-2011
    Location
    Vienna
    MS-Off Ver
    Excel 2002
    Posts
    3

    Question Arithmetic Inconsistencies

    in the course of implementing a checksum column I encountered the following problem, which is more than annoying. Here is my example: cells b1 and c1 contain 2 numbers, cell a1 the sum of b1+c1 as an input!, no formula.

    2 calculations to check if the a1 input is correct:
    version A =if(b1+c1-a1=0;"ok";"false")
    version B =if(b1+c1=a1;"ok";"false")
    Both should deliver the same result, but it is not in several cases. e.g. input in cells a1-b1-c1 is 67,65-56,37-11,28 results in "false" according to formula version A and "ok" in version B.
    Working with 67,66-56,38-11,28 results in "ok" for both versions. This works for many other variants as well and I am really deeply surprised and began to ask myself if the problem is me but excel as this is a very very basic thing.

    I am not a newbie but rather experienced in Excel (>20 years), I use Excel 2002 SP3, settings calc on auto, precision as displayed unchecked.

    Can anybody reproduce this behaviour? Any remarks or hints? Or is just my Excel corrupt? Any suggestions are appreciated.

    P e t e r
    Last edited by DonkeyOte; 01-04-2011 at 01:26 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: formula error ?!

    Hi Peter and welcome to the forum,
    Do these articles apply or help?
    http://www.cpearson.com/excel/rounding.htm
    http://support.microsoft.com/kb/214118
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Arithmetic Inconsistencies

    Peter, welcome to the Board, going forward please try to keep your thread titles specific to the nature of the problem at hand - I've modified on this occasion.

    another link on the topic: http://support.microsoft.com/kb/78113

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Arithmetic Inconsistencies

    I don't understand your question can you post a sample workbook?

    You seem to be using formula to check 3 cells, but your examples have 4?

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Arithmetic Inconsistencies

    Quote Originally Posted by Marcol View Post
    I don't understand your question can you post a sample workbook?

    You seem to be using formula to check 3 cells, but your examples have 4?
    I think it's been thoroughly answered but here is the example as shown in a workbook.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Arithmetic Inconsistencies

    Cheers 6StringJazzer

    I was reading the commas in post#1 as string separators.
    I should have noticed that junglegreen is from Vienna and the commas are in fact decimal points.

    Apologies my oversight.

  7. #7
    Registered User
    Join Date
    01-04-2011
    Location
    Vienna
    MS-Off Ver
    Excel 2002
    Posts
    3

    Re: Arithmetic Inconsistencies

    Thnx to all for the quick reply. Having read the kb's makes me understand the issue somehow, but the suggested workaround does not make me happy at all. My conclusion is that the only way to avoid the problem is to be aware of the issue and build formulas accordingly.
    @Marcol: file is attached (=same as rebuilt by 6StringJazzer).

    Thank you all again,

    P e t e r

  8. #8
    Registered User
    Join Date
    01-04-2011
    Location
    Vienna
    MS-Off Ver
    Excel 2002
    Posts
    3

    Re: Arithmetic Inconsistencies

    Quote Originally Posted by junglegreen View Post
    Thnx to all for the quick reply. Having read the kb's makes me understand the issue somehow, but the suggested workaround does not make me happy at all. My conclusion is that the only way to avoid the problem is to be aware of the issue and build formulas accordingly.
    @Marcol: file is attached (=same as rebuilt by 6StringJazzer).

    Thank you all again,

    P e t e r
    sorry here is the file
    Attached Files Attached Files

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Arithmetic Inconsistencies

    Quote Originally Posted by junglegreen View Post
    sorry here is the file
    Just a note, there is no need to put a + in front of the IF as in your example

    =+IF(B10+C10-A10=0,1,0)

    You get simply use

    =IF(B10+C10-A10=0,1,0)

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Arithmetic Inconsistencies

    Quote Originally Posted by junglegreen View Post
    Having read the kb's makes me understand the issue somehow, but the suggested workaround does not make me happy at all
    @Peter, all I would say to the above is that this is not an Excel specific issue, to quote from the kb link I posted earlier:

    Quote Originally Posted by MS
    Microsoft Excel was designed around the IEEE 754 specification with respect to storing and calculating floating-point numbers.
    IEEE is the Institute of Electrical and Electronics Engineers, an international body that, among other things, determines standards for computer software and hardware.
    The 754 specification is a very widely adopted specification that describes how floating-point numbers should be stored in a binary computer.
    It is popular because it allows floating-point numbers to be stored in a reasonable amount of space and calculations to occur relatively quickly.
    The 754 standard is used in the floating-point units and numeric data processors of nearly all of today's PC-based microprocessors that implement floating-point math, including the Intel, Motorola, Sun, and MIPS processors.

  11. #11
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Arithmetic Inconsistencies

    Quote Originally Posted by DonkeyOte View Post
    @Peter, all I would say to the above is that this is not an Excel specific issue, to quote from the kb link I posted earlier:
    I would like to echo this. It's a problem inherent in numbers. In this case it's due to representing numbers in binary, but you have a similar problem even representing numbers in decimal. For example, you can't represent 1/3 exactly in decimal notation. We know that

    1/3 + 1/3 + 1/3 = 1

    but because 1/3 is represented as a repeating decimal in base 10, you have to decide on some finite number of places to hold. Then you get

    0.3333 + 0.3333 + 0.3333 = 0.9999 ≠ 1

    If you do the same calculation in base 3, you get exact numbers:

    0.1 + 0.1 + 0.1 = 1

    You have the same issue in any language on any computer. Programmers learn not to compare floating point numbers for equality.

    This can also lead to discussion of safe numbers and model numbers, which is a bit far afield for this board and I'm also too rusty on it to do it off the top of my head.

  12. #12
    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: Arithmetic Inconsistencies

    What is surprising to me is that there are revisions (10+ years ago) to IEEE 754 that describe base 10 floating point implementations that would resolve 99% (or 1.98 * 2^-1 if you prefer) of these problems, and it's never (to my knowledge) been implemented. From an FPU standpoint, it's more complex than binary floating point, but the days when that was a limitation have long passed.

    Considering the ubiquity of Excel, I'd have thought that Microsoft would give Intel a sharp nudge in the ribs.
    Last edited by shg; 01-05-2011 at 11:10 AM.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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