File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding preceedence

 
shreya prabhu
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
b1=true,b2=true,b3=false
b3&=b1|b2->this evaluates to false
b3=b3&b1|b2->this evaluates to true
why does it give different result?
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by archana prabhu:
b1=true,b2=true,b3=false
b3&=b1|b2->this evaluates to false
b3=b3&b1|b2->this evaluates to true
why does it give different result?


| has a higher precedence than &=

so b3 &= b1|b2 is the same as b3 &= (b1|b2) which is b3 &= true which is false since b3 is false.

& has a higher precedence than |

so b3 = b3 & b1 | b2 is the same as b3 = (b3 & b1) | b2 = false | true = true.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic