+ Reply to Thread
Results 1 to 2 of 2

Strange Behaviour - Number Storage Bug?

  1. #1
    Registered User
    Join Date
    05-27-2015
    Location
    AZ, USA
    MS-Off Ver
    Professional Plus 2010 (V 14.0.7015.1000 (32-bit)
    Posts
    17

    Strange Behaviour - Number Storage Bug?

    I was doing some calculating of my budget on my Excel spreadsheet today, and found what looks to be a problem with the way Excel stores numbers. But I can't quite figure it out. I've attached a cut-down version of the spreadsheet which still shows the strange behaviour.

    On the spreadsheet, in column A, I have a sequence of numbers - some negative, some positive. They're grouped together in a named range named 'Amounts'.

    The problem arose when I tried to sum them and do some validation.

    In column C, I've worked on the Amounts named range. In C2, I have the sum of the numbers in the Amounts named range that are positive. In C3, I have the sum of the numbers in the Amounts named range that are negative. In C4, I have the sum of all the numbers in the Amounts range. So the value in C2+C3 should = C4, right? As you can see in C6, where I test that C2+C3=C4, that's not the case. A quick look shows that in C4, a value of '1' has snuck in in the 15th (I think) place. Where did it come from, since all the numbers in the named range don't have it?

    In column D, I have the same thing, but instead of using the Amounts named range, I just used the cell range. It has the same problem as column C.

    In column E, I have the same thing, but this time I manually entered the numbers. No phantom '1's appear, but E2+E3 still doesn't = E4 - why not?

    In column F, I did the same thing as column E, but this time instead of manually entering the value in F4, I calculated it (sum(F2:F3)). And this time a phantom '2' snuck in. Why? And - even stranger - despite the phantom '2', the test says that F2+F3=F4 is true!

    Can anybody explain this weirdness?
    Attached Files Attached Files

  2. #2
    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: Strange Behaviour - Number Storage Bug?

    Your computer, and therefore Excel, stores numbers in binary floating-point format, which can't represent most decimals (e.g., 0.1) exactly, in the same way that a finite number of base-10 decimal decimals can't represent 1/3 exactly.

    Use ROUND when testing for equality.
    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)

Similar Threads

  1. Strange Behaviour
    By Mark@Work in forum Excel General
    Replies: 2
    Last Post: 09-30-2008, 12:22 PM
  2. [SOLVED] Strange if(***) behaviour?
    By Excel 2003 - SPB in forum Excel General
    Replies: 6
    Last Post: 08-06-2006, 12:35 PM
  3. Strange cell behaviour
    By madhatter_scfc in forum Excel General
    Replies: 3
    Last Post: 09-14-2005, 05:00 PM
  4. Strange VBA Behaviour
    By Ricko in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-28-2005, 03:05 AM
  5. [SOLVED] Strange behaviour
    By Edgar Thoemmes in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-08-2005, 12:06 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