Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>These are the bitwise operators, all supported in JavaScript:</p> <ul> <li><p><code>op1 &amp; op2</code> -- The <code>AND</code> operator compares two bits and generates a result of 1 if both bits are 1; otherwise, it returns 0.</p></li> <li><p><code>op1 | op2</code> -- The <code>OR</code> operator compares two bits and generates a result of 1 if the bits are complementary; otherwise, it returns 0.</p></li> <li><p><code>op1^ op2</code> -- The <code>EXCLUSIVE-OR</code> operator compares two bits and returns 1 if either of the bits are 1 and it gives 0 if both bits are 0 or 1.</p></li> <li><p><code>~op1</code> -- The C<code>OMPLEMENT</code> operator is used to invert all of the bits of the operand.</p></li> <li><p><code>op1 &lt;&lt; op2</code> -- The <code>SHIFT LEFT</code> operator moves the bits to the left, discards the far left bit, and assigns the rightmost bit a value of 0. Each move to the left effectively multiplies op1 by 2.</p></li> <li><p><code>op1 &gt;&gt; op2</code> -- <code>The SHIFT RIGHT</code> operator moves the bits to the right, discards the far right bit, and assigns the leftmost bit a value of 0. Each move to the right effectively divides op1 in half. The left-most sign bit is preserved.</p></li> <li><p><code>op1 &gt;&gt;&gt; op2</code> -- <code>The SHIFT RIGHT</code> - <code>ZERO FILL</code> operator moves the bits to the right, discards the far right bit, and assigns the leftmost bit a value of 0. Each move to the right effectively divides op1 in half. The left-most sign bit is discarded.</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload