title: Bit operation filter with length consideration
body: <p>I need to write a function that get 2 bytes and a boolean:</p>
  
  <pre><code>filter(int length, uint16_t* A, uint16_t* B, bool checkByZeros)
  </code></pre>
  
  <p>the needed logic is: 
  length is the number of <em>bits</em> to check (i.e. if length = 9 the byte array will contain 2 bytes)
  if checkByZeros is <code>False</code></p>
  
  <p>the function will return <code>true</code> if:</p>
  
  <pre><code>all the bytes set (=1) in A are also set in B
  </code></pre>
  
  <p>in example (length=9):</p>
  
  <pre><code>checkByZeros=True, A:000001111, B:000001111 ==&gt; True
  checkByZeros=True, A:000001111, B:000011111 ==&gt; True
  checkByZeros=True, A:000001111, B:000000111 ==&gt; False
  </code></pre>
  
  <p>if checkByZeros is <code>False</code></p>
  
  <p>the function will return <code>true</code> if:
  all the bytes not-set (=0) in A are also not-set in B
  in example:</p>
  
  <pre><code>checkByZeros=False, A:000001111, B:000001111 ==&gt; True
  checkByZeros=False, A:000001111, B:000011111 ==&gt; False
  checkByZeros=False, A:000001111, B:000000111 ==&gt; True
  </code></pre>
  
  <p>The implementation is quite naiive if i loop over the byte bit by bit but I need a faster bit operation metod.
  Any suggestions? I'm kinda lost because when considering different length the bit operations should ignore bits that are located after lenght</p>