LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default -1^2+1 vs 1-1^2

Scriptick,
In the VBA help of "Operator Precedence", it states that Exponentiation (^)
is higher than Negation (-); i.e. the opposite of Excel.

In "^ Operator Example";
........
MyValue = (-5) ^ 3 ' Returns -125.

Note the barckets.

So it seem you correct that Excel and VBA switch the order of precendence
for these two.

NickHK

"Scriptick" wrote in message
oups.com...
Thanks, exactly what I could not find myself.
However, when I repeat the calculations in the immediate window in the
VBE both expressions -1^2+1 and 1-1^2 evaluate to 0. This is according
to the help function ("The order in which Microsoft Excel performs
operations in formulas", but then in the VBE help), but also confusing.



 
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



All times are GMT +1. The time now is 07:22 AM.

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

About Us

"It's about Microsoft Excel"