title: Mask and extract bits in C
body: <p>I've been looking at posts about masks, but I still can't get my head around how to extract certain bits from a number in C.</p>
  <p>Say if we have an integer number, <code> 0001 1010 0100 1011</code>, its hexadecimal representation is <code>0x1A4B</code>, right? If I want to know the 5th to 7th number, which is <code>101</code> in this case, shall I use <code>int mask= 0x0000 1110 0000 0000, int extract = mask&amp;number</code>?</p>
  <p>Also, how can I check if it is <code>101</code>? I guess <code>==</code> won't work here...</p>