title: Creating masks for specific nibbles
body: <p>How can I - in an as efficient manner as possible - create a mask for all nibbles in an unsigned 64-bit integer that match a certain value?</p>
  
  <p>For example, suppose I have a 64-bit unsigned integer:</p>
  
  <pre><code>0000 0100 0011 0011 0011 0011 0010 0010 0010 0010 0010 0010 0001 0001 0001 0001 
  </code></pre>
  
  <p>And say I only want to allow the nibbles that have values of 0010.
  How can I find those nibbles and create the mask for them.
  In this contrived example I know of course nibbles 5:10 are 0010, and so the corresponding mask to create is:</p>
  
  <pre><code>0000 0000 0000 0000 0000 0000 1111 1111 1111 1111 1111 1111 0000 0000 0000 0000
  </code></pre>
  
  <p>But I'd like to create such masks for any 64-bit unsigned integer and any nibble value. I might be interested in <code>0100</code>, <code>0010</code>, or <code>1000</code> nibbles for example.</p>