 <p>You had your parentheses in the wrong place:</p> <pre><code>function equal(n1, n2){ var bool = (n1 ^ n2) &gt;= 0 ? true : false; document.write("&lt;div&gt;" + bool + " (" + (n1^n2) + ")&lt;/div&gt;"); } </code></pre> <p>Here's an <a href="http://jsfiddle.net/qSwFt/1/" rel="nofollow">updated fiddle</a> with results matching what you expect.</p> <p>This is important in this case because all of the bitwise operators are of <a href="https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence" rel="nofollow">lower precedence</a> than the relational comparison operators. Also note that the conditional operator (<code>?:</code>) is of lower precedence than all of the bitwise operators, so there's no need for another set of parentheses around the entire condition.</p>