PC Review


Reply
Thread Tools Rate Thread

Bad Calculation in Excel

 
 
=?Utf-8?B?UGVycGxleGVk?=
Guest
Posts: n/a
 
      10th Sep 2007
The sum of these numbers should be zero (0). However, no matter what the
cell format, the following numbers add up to 3.55271E-15. Any ideas why?

0.94
-5
5
25
-25
3.06
-25
21
0

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9jaw==?=
Guest
Posts: n/a
 
      10th Sep 2007
I have tried it with the SUM cell formatted as number to two decimals and it
worked fine - 0.00
(Excel 2003)
--
Traa Dy Liooar

Jock


"Perplexed" wrote:

> The sum of these numbers should be zero (0). However, no matter what the
> cell format, the following numbers add up to 3.55271E-15. Any ideas why?
>
> 0.94
> -5
> 5
> 25
> -25
> 3.06
> -25
> 21
> 0
>

 
Reply With Quote
 
David Biddulph
Guest
Posts: n/a
 
      10th Sep 2007
Fixed point binary representation. Try to calculate the exact binary
representation of 0.94 (or of 3.06).
Same reason that you may get similar small rounding errors with a decimal
calculation if you've got 10/3 + 10/3 + 10/3 and try to subtract 10 from the
result.
--
David Biddulph

"Perplexed" <(E-Mail Removed)> wrote in message
news:4A5787D4-CB44-4DA1-ADED-(E-Mail Removed)...
> The sum of these numbers should be zero (0). However, no matter what the
> cell format, the following numbers add up to 3.55271E-15. Any ideas why?
>
> 0.94
> -5
> 5
> 25
> -25
> 3.06
> -25
> 21
> 0
>



 
Reply With Quote
 
=?Utf-8?B?UGVycGxleGVk?=
Guest
Posts: n/a
 
      10th Sep 2007
Thanks for the reply. Here's more info on this problem.
1. These cells are summed up in a pivot table where the pivot table has the
format of accounting (to dash out zeros in display).
2. Although the sum of these numbers should be net flat zero, it shows up
as (0.00) because I have a conditional formatting set to show negative
numbers in red 0.00 format.
3. All other zero numbers do show as "-" except for the cell that sums up
these numbers.


"Jock" wrote:

> I have tried it with the SUM cell formatted as number to two decimals and it
> worked fine - 0.00
> (Excel 2003)
> --
> Traa Dy Liooar
>
> Jock
>
>
> "Perplexed" wrote:
>
> > The sum of these numbers should be zero (0). However, no matter what the
> > cell format, the following numbers add up to 3.55271E-15. Any ideas why?
> >
> > 0.94
> > -5
> > 5
> > 25
> > -25
> > 3.06
> > -25
> > 21
> > 0
> >

 
Reply With Quote
 
Mark Lincoln
Guest
Posts: n/a
 
      10th Sep 2007
You can put your calculation in a ROUND function. Round to the number
of digits needed.

Conversely, you can test for the sum being less than the smallest
number you'll accept as not zero and force the calculation to zero if
that occurs. As an example:

=IF(SUM(A1:A8)<.0001,0,SUM(A1:A8))

Mark Lincoln

On Sep 10, 11:08 am, Perplexed <Perple...@discussions.microsoft.com>
wrote:
> Thanks for the reply. Here's more info on this problem.
> 1. These cells are summed up in a pivot table where the pivot table has the
> format of accounting (to dash out zeros in display).
> 2. Although the sum of these numbers should be net flat zero, it shows up
> as (0.00) because I have a conditional formatting set to show negative
> numbers in red 0.00 format.
> 3. All other zero numbers do show as "-" except for the cell that sums up
> these numbers.
>
>
>
> "Jock" wrote:
> > I have tried it with the SUM cell formatted as number to two decimals and it
> > worked fine - 0.00
> > (Excel 2003)
> > --
> > Traa Dy Liooar

>
> > Jock

>
> > "Perplexed" wrote:

>
> > > The sum of these numbers should be zero (0). However, no matter what the
> > > cell format, the following numbers add up to 3.55271E-15. Any ideas why?

>
> > > 0.94
> > > -5
> > > 5
> > > 25
> > > -25
> > > 3.06
> > > -25
> > > 21
> > > 0- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
=?Utf-8?B?UGVycGxleGVk?=
Guest
Posts: n/a
 
      10th Sep 2007
Thanks that will come in handy for other need, however, in this case, it
doesn't work because using the Fixed function, the sum function shows 0.

"David Biddulph" wrote:

> Fixed point binary representation. Try to calculate the exact binary
> representation of 0.94 (or of 3.06).
> Same reason that you may get similar small rounding errors with a decimal
> calculation if you've got 10/3 + 10/3 + 10/3 and try to subtract 10 from the
> result.
> --
> David Biddulph
>
> "Perplexed" <(E-Mail Removed)> wrote in message
> news:4A5787D4-CB44-4DA1-ADED-(E-Mail Removed)...
> > The sum of these numbers should be zero (0). However, no matter what the
> > cell format, the following numbers add up to 3.55271E-15. Any ideas why?
> >
> > 0.94
> > -5
> > 5
> > 25
> > -25
> > 3.06
> > -25
> > 21
> > 0
> >

>
>
>

 
Reply With Quote
 
David Biddulph
Guest
Posts: n/a
 
      10th Sep 2007
I wasn't suggesting that you should use the Excel FIXED function (which
rounds a number to the specified number of decimals, formats the number in
decimal format using a period and commas, and returns the result as text).

I was saying that in a fixed point binary representation (which is what
Excel and most computing calculations use) you are likely to get rounding
errors when you try to represent decimal numbers. The only decimal numbers
that can be expressed exactly in binary are numbers such as 0.5, 0.25,
0.125, ... and their multiples. Numbers such as 0.1 do not have an exact
binary representation.
--
David Biddulph

"Perplexed" <(E-Mail Removed)> wrote in message
news:EDFF25D1-E72F-4ECD-83BF-(E-Mail Removed)...
> Thanks that will come in handy for other need, however, in this case, it
> doesn't work because using the Fixed function, the sum function shows 0.


> "David Biddulph" wrote:
>
>> Fixed point binary representation. Try to calculate the exact binary
>> representation of 0.94 (or of 3.06).
>> Same reason that you may get similar small rounding errors with a decimal
>> calculation if you've got 10/3 + 10/3 + 10/3 and try to subtract 10 from
>> the
>> result.


>> "Perplexed" <(E-Mail Removed)> wrote in message
>> news:4A5787D4-CB44-4DA1-ADED-(E-Mail Removed)...
>> > The sum of these numbers should be zero (0). However, no matter what
>> > the
>> > cell format, the following numbers add up to 3.55271E-15. Any ideas
>> > why?
>> >
>> > 0.94
>> > -5
>> > 5
>> > 25
>> > -25
>> > 3.06
>> > -25
>> > 21
>> > 0
>> >

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?UGVycGxleGVk?=
Guest
Posts: n/a
 
      10th Sep 2007
This would work but I need to display legitimate negative numbers. Thanks.

"Mark Lincoln" wrote:

> You can put your calculation in a ROUND function. Round to the number
> of digits needed.
>
> Conversely, you can test for the sum being less than the smallest
> number you'll accept as not zero and force the calculation to zero if
> that occurs. As an example:
>
> =IF(SUM(A1:A8)<.0001,0,SUM(A1:A8))
>
> Mark Lincoln
>
> On Sep 10, 11:08 am, Perplexed <Perple...@discussions.microsoft.com>
> wrote:
> > Thanks for the reply. Here's more info on this problem.
> > 1. These cells are summed up in a pivot table where the pivot table has the
> > format of accounting (to dash out zeros in display).
> > 2. Although the sum of these numbers should be net flat zero, it shows up
> > as (0.00) because I have a conditional formatting set to show negative
> > numbers in red 0.00 format.
> > 3. All other zero numbers do show as "-" except for the cell that sums up
> > these numbers.
> >
> >
> >
> > "Jock" wrote:
> > > I have tried it with the SUM cell formatted as number to two decimals and it
> > > worked fine - 0.00
> > > (Excel 2003)
> > > --
> > > Traa Dy Liooar

> >
> > > Jock

> >
> > > "Perplexed" wrote:

> >
> > > > The sum of these numbers should be zero (0). However, no matter what the
> > > > cell format, the following numbers add up to 3.55271E-15. Any ideas why?

> >
> > > > 0.94
> > > > -5
> > > > 5
> > > > 25
> > > > -25
> > > > 3.06
> > > > -25
> > > > 21
> > > > 0- Hide quoted text -

> >
> > - Show quoted text -

>
>
>

 
Reply With Quote
 
Mark Lincoln
Guest
Posts: n/a
 
      10th Sep 2007
Well, of course you do. Leave it to me to ignore the negative numbers
in your example. Let's modify my example:

=IF(ABS(SUM(A1:A8))<.0001,0,SUM(A1:A8))

That should work better. In this example, any sum within +/-.0001 of
zero becomes zero.

Sorry for the confusion.

Mark Lincoln

On Sep 10, 2:30 pm, Perplexed <Perple...@discussions.microsoft.com>
wrote:
> This would work but I need to display legitimate negative numbers. Thanks.
>
>
>
> "Mark Lincoln" wrote:
> > You can put your calculation in a ROUND function. Round to the number
> > of digits needed.

>
> > Conversely, you can test for the sum being less than the smallest
> > number you'll accept as not zero and force the calculation to zero if
> > that occurs. As an example:

>
> > =IF(SUM(A1:A8)<.0001,0,SUM(A1:A8))

>
> > Mark Lincoln

>
> > On Sep 10, 11:08 am, Perplexed <Perple...@discussions.microsoft.com>
> > wrote:
> > > Thanks for the reply. Here's more info on this problem.
> > > 1. These cells are summed up in a pivot table where the pivot table has the
> > > format of accounting (to dash out zeros in display).
> > > 2. Although the sum of these numbers should be net flat zero, it shows up
> > > as (0.00) because I have a conditional formatting set to show negative
> > > numbers in red 0.00 format.
> > > 3. All other zero numbers do show as "-" except for the cell that sums up
> > > these numbers.

>
> > > "Jock" wrote:
> > > > I have tried it with the SUM cell formatted as number to two decimals and it
> > > > worked fine - 0.00
> > > > (Excel 2003)
> > > > --
> > > > Traa Dy Liooar

>
> > > > Jock

>
> > > > "Perplexed" wrote:

>
> > > > > The sum of these numbers should be zero (0). However, no matter what the
> > > > > cell format, the following numbers add up to 3.55271E-15. Any ideas why?

>
> > > > > 0.94
> > > > > -5
> > > > > 5
> > > > > 25
> > > > > -25
> > > > > 3.06
> > > > > -25
> > > > > 21
> > > > > 0- Hide quoted text -

>
> > > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
=?Utf-8?B?UGVycGxleGVk?=
Guest
Posts: n/a
 
      11th Sep 2007
Thanks all. I solved it for this purpose by using the ROUND() function in
the display since I vlookup the pivot table values. Appreciate all your help.

"Mark Lincoln" wrote:

> Well, of course you do. Leave it to me to ignore the negative numbers
> in your example. Let's modify my example:
>
> =IF(ABS(SUM(A1:A8))<.0001,0,SUM(A1:A8))
>
> That should work better. In this example, any sum within +/-.0001 of
> zero becomes zero.
>
> Sorry for the confusion.
>
> Mark Lincoln
>
> On Sep 10, 2:30 pm, Perplexed <Perple...@discussions.microsoft.com>
> wrote:
> > This would work but I need to display legitimate negative numbers. Thanks.
> >
> >
> >
> > "Mark Lincoln" wrote:
> > > You can put your calculation in a ROUND function. Round to the number
> > > of digits needed.

> >
> > > Conversely, you can test for the sum being less than the smallest
> > > number you'll accept as not zero and force the calculation to zero if
> > > that occurs. As an example:

> >
> > > =IF(SUM(A1:A8)<.0001,0,SUM(A1:A8))

> >
> > > Mark Lincoln

> >
> > > On Sep 10, 11:08 am, Perplexed <Perple...@discussions.microsoft.com>
> > > wrote:
> > > > Thanks for the reply. Here's more info on this problem.
> > > > 1. These cells are summed up in a pivot table where the pivot table has the
> > > > format of accounting (to dash out zeros in display).
> > > > 2. Although the sum of these numbers should be net flat zero, it shows up
> > > > as (0.00) because I have a conditional formatting set to show negative
> > > > numbers in red 0.00 format.
> > > > 3. All other zero numbers do show as "-" except for the cell that sums up
> > > > these numbers.

> >
> > > > "Jock" wrote:
> > > > > I have tried it with the SUM cell formatted as number to two decimals and it
> > > > > worked fine - 0.00
> > > > > (Excel 2003)
> > > > > --
> > > > > Traa Dy Liooar

> >
> > > > > Jock

> >
> > > > > "Perplexed" wrote:

> >
> > > > > > The sum of these numbers should be zero (0). However, no matter what the
> > > > > > cell format, the following numbers add up to 3.55271E-15. Any ideas why?

> >
> > > > > > 0.94
> > > > > > -5
> > > > > > 5
> > > > > > 25
> > > > > > -25
> > > > > > 3.06
> > > > > > -25
> > > > > > 21
> > > > > > 0- Hide quoted text -

> >
> > > > - Show quoted text -- Hide quoted text -

> >
> > - Show quoted text -

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Interrupting long calculations in Excel? Hi all, I am having a verylong calculation in Excel using VBA. Of course I know I can hit ESC orCTRL+BREAK to interrupt the VBA program. But I found due to too long runningprocess, the Excel window stop to LunaMoon Microsoft Excel Discussion 3 31st Jul 2008 04:47 PM
Interrupting long calculations in Excel? Hi all, I am having a verylong calculation in Excel using VBA. Of course I know I can hit ESC orCTRL+BREAK to interrupt the VBA program. But I found due to too long runningprocess, the Excel window stop to LunaMoon Microsoft Excel Programming 3 31st Jul 2008 04:47 PM
Interrupting long calculations in Excel? Hi all, I am having a verylong calculation in Excel using VBA. Of course I know I can hit ESC orCTRL+BREAK to interrupt the VBA program. But I found due to too long runningprocess, the Excel window stop to LunaMoon Microsoft Excel Misc 3 31st Jul 2008 04:47 PM
Excel Automatic Calculation makes Excel the Active Application Clementius Microsoft Excel Discussion 1 4th May 2007 08:17 AM
Excel 2003 versus Excel 2007 calculation speed Stan Brown Microsoft Excel Discussion 7 10th Apr 2007 07:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:34 AM.