views:

42

answers:

4

The operator precedence table I can find is:

https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence

according to the table, both '>>' and '*' are left-to-right associate, and '>>' have higher precedence, so I think a >> b * c should explain as (a >> b) * c however, my test in Firefox (using Firebug), tell me:

0x11 >> 1      ....    8
0x11 >> 1 * 2  ....    4

Which confuses me a lot, should it be 16 instead?

OK, I understand that we always should use parentheses when precedence is not clear, however there should be a rule or explain of what is happening?

+2  A: 

According to the table you linked to, * has higher precedence (5) than >> (7); higher precedence is listed first in that table, though confusingly, lower numbers are used to indicate higher precedence.

Brian Campbell
thank you... my mistake...
ccppjava
+1  A: 

According to the table you linked, multiplication has higher precedence (5) than bit-shifting (7).

From the top of the table:

The following table is ordered from highest (1) to lowest (17) precedence.

Daniel Vandersluis
+1  A: 

No, it says that * has higher precedence than >>. :)

Deniz Dogan
+2  A: 

if I look at that table, * has a higher precedence over >>.

Lekensteyn
as it is my mis-understanding, which does confuse me for about an hour. I am stupid, thank you all for so many replies, the answer goes to the quickest answer, sorry if this is not that fair...
ccppjava