Thread: Excel Math Bug
View Single Post
  #89   Report Post  
Posted to microsoft.public.excel.programming,sci.math
Kevin O'Neill Kevin O'Neill is offline
external usenet poster
 
Posts: 6
Default Excel Math Bug



=================================================


No break is needed if the reason for the existence of order-of-operation
rules is understood.


Kevin O'Neill

=================================================


"fred" wrote in message ...
So if a physicist writes an equation he has to include the 'rules of
calculation' for others to use it? Give me a break.



"Dik T. Winter" wrote in message
...
In article "fred"

writes:
Do any of you SCI.MATH whizes want to weigh in on this?


Well, contrary to some responders I do not read this in an excel newsgroup
(I have no reason to read such a newsgroup...).

MS Excel calculates "=-5^2" as 25, not as -25.


Yes, that is one of the possibilities.

This is because 'negation' is handled first in Excel. (!?)


Right, there are quite a few programming languages that do the same.

If you put a zero in the equation,
as in "=0-5^2", your answer changes to -25.


Indeed.

Is this in line with standard math rules?


Yup, both are in line with standard math rules. There are no standard
rules about how unary operators are handled.

Is negation different than subtraction?


Yes, indeed.

I've had lots of math and as far as I know
negation and subtraction are the same thing.


When you look at the definition for rings, and stuff like that, you will
find that they are very different. If you look you will find that
a - b
is just shorthand for
a + b'.
where b' is the negative of b. So
0 - 5^2
is shorthand for
0 + (5^2)'

There are more places where some programming languages do not give you
what you thought they should do. Exponentiaton is an example. What is:
a ^ b ^ c?
There is not strict left to right rule in mathematics...

You may wonder, why should I do
a - b + c
from left to right? Well, actually you have to transform it to something
that is basic mathematics:
a + (-b) + c
and now it does not matter what way you do the operations.
where (5^2)' is the negative of 5^2.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland,

+31205924131
home: bovenover 215, 1025 jn amsterdam, nederland;

http://www.cwi.nl/~dik/