Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Question 1</strong></p> <blockquote> <p>Why is ~0xF equal to 0xFFFFFFF0?</p> </blockquote> <p>First, this means you run this on a 32-bit machine. That means 0xF is actually <code>0x0000000F</code> in <a href="http://en.wikipedia.org/wiki/Hexadecimal" rel="noreferrer">hexadecimal</a>, </p> <p>And that means 0xF is <code>0000 0000 0000 0000 0000 0000 0000 1111</code> in binary representation.</p> <p>The <code>~</code> operator means the NOT operation. Tt changes <em>every 0 to 1 and every 1 to 0</em> in the binary representation. That would make ~0xF to be: <code>1111 1111 1111 1111 1111 1111 1111 0000</code> in binary representation.</p> <p>And that is actually <code>0xFFFFFFF0</code>.</p> <p>Note that if you do this on a 16-bit machine, the answer of <code>~0xF</code> would be <code>0xFFF0</code>.</p> <p><strong>Question 2</strong></p> <p>You wrote the wrong statement, it should be <code>0xF &amp; 0x1</code>. Note that <code>0x1</code> <code>0x01</code>, <code>0x001</code>, and <code>0x0001</code> are all the same. So let’s change this hexdecimal number to binary representation:</p> <p><code>0xF</code> would be:</p> <p><code>0000 0000 0000 0000 0000 0000 0000 1111</code></p> <p>and <code>0x1</code> would be:</p> <p><code>0000 0000 0000 0000 0000 0000 0000 0001</code></p> <p>The <code>&amp;</code> operation follows the following rules:</p> <pre><code>0 &amp; 0 = 0 0 &amp; 1 = 0 1 &amp; 0 = 0 1 &amp; 1 = 1 </code></pre> <p>So doing that to every bit, you get the result:</p> <p><code>0000 0000 0000 0000 0000 0000 0000 0001</code></p> <p>which is actually <code>0x1</code>.</p> <p><strong>Additional</strong></p> <p><code>|</code> means bitwise OR operation. It follows:</p> <pre><code>0 | 0 = 0 0 | 1 = 1 1 | 0 = 1 1 | 1 = 1 </code></pre> <p><code>^</code> means bitwise XOR operation. It follows:</p> <pre><code>0 ^ 0 = 0 0 ^ 1 = 1 1 ^ 0 = 1 1 ^ 1 = 0 </code></pre> <p>You can get more information <a href="http://en.wikipedia.org/wiki/Bitwise_operation#XOR" rel="noreferrer">here</a>.</p>
    singulars
    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.
    3. 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