Rad & Dot Net - Digital Warrior

Assorted ramblings (and vents!!) from a techie on the sunny shores of Kenya, East Africa

Friday, January 07, 2005

Excel Dilemmas

Tinkering around with Excel and VBA has led me to some pretty interesting discoveries.

If you enter the following formula in a cell

-4^4

It returns the value 254, which is correct as far as elementary mathematics is concerned. -4 squared is +254

However the same expression if executed through code, either VB proper or C# or even VBA, the exact same expression yields -254

And if you think about it, the second expression is also correct insofar as most languages have the precedence of power as higher than that of the negative.

Which is to say if you drive Excel using VBA and calculate cell values using both VBA and Excel forumulae, you are in for the high jump.

The dilemma is that changing this behaviour in Excel could precipitate riots in the the current user base of Excel which runs in the millions if not billions who will probably not take kindly to having to change their worksheets and macros. Any attempts to do this will result in the same gymnastics along the lines of the different base dates (January 1, 1900 and January 2, 1904) that Excel supports. Talk about being between a rock and a hard place!

0 Comments:

Post a Comment

<< Home