• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

regarding preceedence

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic