Thread: Excel Math Bug
View Single Post
  #78   Report Post  
Posted to microsoft.public.excel.programming,sci.math
Phil Carmody Phil Carmody is offline
external usenet poster
 
Posts: 8
Default Excel Math Bug

"Harlan Grove" writes:

"Alan Beban" wrote...
...
. . . (which, incidentally, seems to have been resolved in C
the same way as it is in Excel, which is hard to blame Microsoft for)

...

What are you talking about?!

Unless you mean to recommend that Excel users stop using the ^ operator and
use the POWER function instead, Excel and C don't work the same. C lacks an
exponentiation operator. It includes a function named pow in its standard
library. It has a ^ operator, but it's bitwise XOR.


He probably means that unary minus has a significantly higher precedence
than subtraction, so much so that it has a strictly higher precedence
than at least one operator that one would commonly view as being of a
strictly higher precdence than subtraction.

Therefore there is a concrete example of an expression which is
interpretted differently in C than it would be using people like you's
conventions.

In C's case, the precedence inversion is with the multiplicative family
of operators.
e.g. compare C's interpretation of -2%3 as (-2)%3 rather than -(2%3).

Simple, eh? Barely need for an interrobang.

Phil
--
1st bug in MS win2k source code found after 20 minutes: scanline.cpp
2nd and 3rd bug found after 10 more minutes: gethost.c
Both non-exploitable. (The 2nd/3rd ones might be, depending on the CRTL)