title: Why does (boolean ^ int > 0) work?
body: <p>When you try to do something like this:</p>
  
  <pre><code>if (true ^ 1) {
    //do something
  }
  </code></pre>
  
  <p>the compiler reasonably says that operator <code>^</code> is not defined for argument types boolean and int.
  But if you use it like this:</p>
  
  <pre><code>if (true ^ 1 &gt; 0) {
    //do something
  }
  </code></pre>
  
  <p>the code compiles (for Java 8 at least) and flawlessly works.
  Basically these operations:</p>
  
  <pre><code>false ^ -1 &gt; 0 
  false ^ 1 &gt; 0
  true ^ -1 &gt; 0
  true ^ 1 &gt; 0
  </code></pre>
  
  <p>Act like a valid logical XOR:</p>
  
  <pre><code>     | ^
  -----+--
   F F | F
   F T | T
   T F | T
   T T | F
  </code></pre>
  
  <p>Could anybody please explain what happens under the hood?</p>