Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Sum - Sum < Zero ??? How is it? Bug in Excel formula?

Hi, I just found this "feature" at Excel formulas today.

Please, have a look at: http://danielgudang.multiply.com/journal/item/192
(in portuguese, but images show all)


Let me explain:


some cell C1 = sum (C2:C5)
some cell D1 = sum (D2:D5)
some cell E1 = sum (E2:E5)


A1 = C1 - D1 - E1
B1 = C1 - (D1 + E1)


A1 = B1 ??? Oh, not always!


Sometimes A1 will be +0, sometimes -0.


Really strange!

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default Sum - Sum < Zero ??? How is it? Bug in Excel formula?

You're likely looking at rounding errors.

Excel is limited to 15 digits of precision in its calculation.

Dave
--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


"danieldc" wrote:

Hi, I just found this "feature" at Excel formulas today.

Please, have a look at: http://danielgudang.multiply.com/journal/item/192
(in portuguese, but images show all)


Let me explain:


some cell C1 = sum (C2:C5)
some cell D1 = sum (D2:D5)
some cell E1 = sum (E2:E5)


A1 = C1 - D1 - E1
B1 = C1 - (D1 + E1)


A1 = B1 ??? Oh, not always!


Sometimes A1 will be +0, sometimes -0.


Really strange!


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default Sum - Sum < Zero ??? How is it? Bug in Excel formula?

Here's an example of rounding errors:

I have in the formula =LN(RAND()^2) in C2:E5 and then I sum C2:C5, D2:D5,
and E5 and then do your formulas in A1 and B1. So far, everything is as you
create it.

Then I widened the cells so that 15 digits are displayed.

Finally, in A4 I put the formula =IF(A1=B1,"",1) so that a 1 shows if the
two cells are not exactly equal. Pressing F9 repeatedly yields a 1
eventually (and my guess is that the occurrence of 1s could be predicted if
one were so inclined.) In any event, the following two values triggered the
1:

0.0102071029117790000

and

0.0102071029117798000

As you can see these are not equal but only very approximately equal, due to
Excel's 15 digit of precision calculation limit.

Dave

--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


"danieldc" wrote:

Hi, I just found this "feature" at Excel formulas today.

Please, have a look at: http://danielgudang.multiply.com/journal/item/192
(in portuguese, but images show all)


Let me explain:


some cell C1 = sum (C2:C5)
some cell D1 = sum (D2:D5)
some cell E1 = sum (E2:E5)


A1 = C1 - D1 - E1
B1 = C1 - (D1 + E1)


A1 = B1 ??? Oh, not always!


Sometimes A1 will be +0, sometimes -0.


Really strange!


  #4   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Sum - Sum < Zero ??? How is it? Bug in Excel formula?

Not just an excel feature, but a well documented issue with binary fractions.
Basically, some decimals cannot be represented exactly in binary (same way
1/3 cannot be represented exactly as a decimal - using base 10 anyway).

More he
http://cpearson.com/excel/rounding.htm

Also, if you search on this site, you should find several threads on this
issue w/explanations from folks who are much more knowledgeable than I (Jerry
Lewis had some good posts on this).

My suggestion is to use the Round function whenever you use a conditional
statement involving numbers that are or could be decimals.


"danieldc" wrote:

Hi, I just found this "feature" at Excel formulas today.

Please, have a look at: http://danielgudang.multiply.com/journal/item/192
(in portuguese, but images show all)


Let me explain:


some cell C1 = sum (C2:C5)
some cell D1 = sum (D2:D5)
some cell E1 = sum (E2:E5)


A1 = C1 - D1 - E1
B1 = C1 - (D1 + E1)


A1 = B1 ??? Oh, not always!


Sometimes A1 will be +0, sometimes -0.


Really strange!


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Sum - Sum < Zero ??? How is it? Bug in Excel formula?

On 29 mar, 17:08, Dave F wrote:
Here's an example of rounding errors:

I have in the formula =LN(RAND()^2) in C2:E5 and then I sum C2:C5, D2:D5,
and E5 and then do your formulas in A1 and B1. So far, everything is as you
create it.


Yes, you got it.


As you can see these are not equal but only very approximately equal, due to
Excel's 15 digit of precision calculation limit.


I had believed that Excel's 15 digit limit of precision calculation
could be enough...
But now, I changed my mind.

I will put some "truncate()" function at all places when I need
"exact" values.

Maybe that truncate(A1; 2) = truncate(B1; 2) will be always evaluated
TRUE.

yours, Daniel
from Brazil



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default Sum - Sum < Zero ??? How is it? Bug in Excel formula?

That will work.

This is a bit more efficient:

=ABS(A1-B1)<0.01

In article . com,
"danieldc" wrote:

Maybe that truncate(A1; 2) = truncate(B1; 2) will be always evaluated
TRUE.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Formula Doesn't Execute (Shows formula-not the calcuation) Keys1970 Excel Discussion (Misc queries) 4 November 15th 06 02:12 PM
Excel 2002 formula displayed not value formula option not checked Dean Excel Worksheet Functions 1 February 28th 06 02:31 PM
How do I view formula results intead of formula in excel? davidinatlanta Excel Worksheet Functions 4 February 7th 06 03:02 PM
i edit a formula (excel) then it displays formula not answer caiman Excel Discussion (Misc queries) 2 September 9th 05 02:09 AM
Converting an Excel formula to an Access query formula Adam Excel Discussion (Misc queries) 1 December 15th 04 03:38 AM


All times are GMT +1. The time now is 01:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"