• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

java cert study guide question

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone breakdown this problem and explain it for me, the study guide's answer is 11. the problem is 8 | 9 & 10 ^ 11. I understand the order of precedence is (8|((9&10)^11)).
I want to be able to understand how this problem works.
thanks.
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Otto.
"&" returns a "1" in the resultant bit if and only if both bits fed to it are "1".
"^" returns a "1" in the resultant bit if and only if the bits fed to it are unequal (i.e., the input is "0" and "1", or the input is "1" and "0").
"|" returns a "1" in the resultant bit if either of the bits fed to it are "1".
Now, for the bit representations of your four ints:
8 = 00000000 00000000 00000000 00001000
9 = 00000000 00000000 00000000 00001001
10 = 00000000 00000000 00000000 00001010
11 = 00000000 00000000 00000000 00001011
Since you seem to understand the order of operations, Otto, we can see that, by the definitions above:
9 & 10 = 000000000 00000000 00000000 00001000 = 8
8 ^ 11 = 000000000 00000000 00000000 00000011 = 3
8 | 3 = 000000000 00000000 00000000 00001011 = 11
Therefore, 8 | 9 & 10 ^ 11 = 11.
HTH
Art
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is an EXCELLENT Explanation.
thanks a TON!
Usman
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic