Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your going to need more tools in your toolkit to answer those questions than shifting. </p> <p>I think you'll need to start very basic about how numbers are represented in binary. Then you'll want to think about how to set and clear specific bits in that number, or a group of bits at the same time. You'll need to know how to test to see if a certain group of bits is set and about masking. You'll have to be able to do all the above with the bitwise operators and/or/xor/inversion/etc operators. Then you'll want to know about shifting -- moving bits left and right by a specific number of spaces. You'll want to know what happens to the bits left "empty". Is it filled with a 1 or a 0? When is it filled with a 1 or 0?</p> <p>Googling "bitwise operations tutorial" seems to have come up with some promising results to begin with. But here's some basics to test yourself against to make sure you understand</p> <pre><code>// 1234 in hex, you understand this is not 1234 in decimal? Do you understand // how specifying in hex makes it easier to think about the binary representation? unsigned short i = 0x1234; // flip all the bits in 0x1234 printf("%04x", ~i); // Test - Is the most significant bit set? // mask is a binary number with the most significant bit set. Do // you understand why this is so? unsigned short mask = 0x8000; if ((mask &amp; i) == mask) { printf("bit set!"); } else { printf("bit cleared!"); } // set the most significant bit i = i | mask; printf("Set the MSB of i, check it out: %i\n", i) // set the second most significant bit // Do you see how by shifting mask right one it becomes the next most significant bit? i = i | (mask &gt;&gt; 1); </code></pre> <p>Good Luck!</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. 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.
    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