Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Lets make it the best way to shift <code>N</code> bits in the array of 8 bit integers.</p> <pre><code>N - Total number of bits to shift F = (N / 8) - Full 8 bit integers shifted R = (N % 8) - Remaining bits that need to be shifted </code></pre> <p>I guess from here you would have to find the most optimal way to make use of this data to move around ints in an array. Generic algorithms would be to apply the full integer shifts by starting from the right of the array and moving each integer <code>F</code> indexes. Zero fill the newly empty spaces. Then finally perform an <code>R</code> bit shift on all of the indexes, again starting from the right.</p> <p>In the case of shifting <code>0xBC</code> by <code>R</code> bits you can calculate the overflow by doing a bitwise AND, and the shift using the bitshift operator:</p> <pre><code>// 0xAB shifted 4 bits is: (0xAB &amp; 0x0F) &gt;&gt; 4 // is the overflow (0x0A) 0xAB &lt;&lt; 4 // is the shifted value (0xB0) </code></pre> <p>Keep in mind that the 4 bits is just a simple mask: 0x0F or just 0b00001111. This is easy to calculate, dynamically build, or you can even use a simple static lookup table.</p> <p>I hope that is generic enough. I'm not good with C/C++ at all so maybe someone can clean up my syntax or be more specific.</p> <p>Bonus: If you're crafty with your C you might be able to fudge multiple array indexes into a single 16, 32, or even 64 bit integer and perform the shifts. But that is prabably not very portable and I would recommend against this. Just a possible optimization. </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. This table or related slice is empty.
    1. 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