Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>JavaScript has the usual assortment of bitwise operators, <code>|</code>, <code>&amp;</code>, <code>~</code>, etc.; details in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" rel="nofollow">the specification</a>.</p> <p>The following sections will be particularly useful:</p> <ul> <li>Section 11.4.8: Bitwise NOT (<code>~</code>)</li> <li>Section 11.7: Bitwise Shift Operators (<code>&lt;&lt;</code> and <code>&gt;&gt;</code>)</li> <li>Section 11.10: Binary Bitwise Operators (<code>|</code> and <code>&amp;</code>)</li> </ul> <p>Note that JavaScript's numbers are all floating point (see Section 8.5, <em>The Number Type</em>, in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" rel="nofollow">the specification</a>), but the bitwise operations are defined in terms of integers. So for instance, the definition of the bitwise NOT operator:</p> <blockquote> <p><strong>11.4.8 Bitwise NOT Operator ( <code>~</code> )</strong> <br>The production <code>UnaryExpression : ~ UnaryExpression</code> is evaluated as follows: <br>1. Let <code>expr</code> be the result of evaluating <code>UnaryExpression</code>. <br>2. Let <code>oldValue</code> be <code>ToInt32(GetValue(expr))</code>. <br>3. Return the result of applying bitwise complement to <code>oldValue</code>. The result is a signed 32-bit integer.</p> </blockquote> <p>Any decent implementation will be able to handle these efficiently, avoiding unnecessary conversions from <code>Number</code> to internal integer and back.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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