Bitwise masking
<p>Assuming an environment where <code>long int</code> is a 64-bit type, suppose I have an <code>long int = 0x0123456789ABCDEF</code>  and I want to get the byte that represents 89. Would this line work?</p>

<pre><code>n = (n &gt;&gt; (b &lt;&lt; 3)) &amp; 0xFF;
</code></pre>

<p>where n is the <code>long int</code> and b is the byte I want. So <code>b</code> would be 3 and shifting it left 3 would multiply it by 8 changing it into a byte so shifting should look like this 0x0123456789. Is using &amp; 0xFF the right way to mask to get the last byte?</p>