• Post Reply Bookmark Topic Watch Topic
  • New Topic

Operator precedence  RSS feed

 
Divya Eknath
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody please tell me the precedence of bitwise/ligical operators:&,^ and |?
In some books its given as & ^ |, while in others it is & | ^.
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
&,^, |

Expressions, Statements, and Blocks
 
Simeon Cherniy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The order is: & ^ |
x^y = (x | !y) & (!x | y)
That's why the priority of XOR(^) is higher
 
Simeon Cherniy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
x^y = (x | y) & (!x | !y)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!