title: Finding whether a signed and an unsigned integer are both even or both odd
body: <p>I have an <code>int m</code> and an <code>unsigned int j</code> and want to determine whether they are both even or both odd.</p>
  
  <p>In the past I've been using</p>
  
  <pre><code>if((int(j)+m)%2)
  </code></pre>
  
  <p>to catch the case that only one is odd. But I'm concerned about the casting to <code>int</code> incorrectly changing the odd-even-ness of <code>j</code>.</p>
  
  <p>Do either of these run into problems?</p>
  
  <pre><code>if(!(j%2)!=!(m%2))
  if(bool(j%2)!=bool(j%2))
  </code></pre>
  
  <p>I know that</p>
  
  <pre><code>if(j%2!=m%2)
  </code></pre>
  
  <p>doesn't work because 'm%2' will produce <code>-1</code> when <code>m</code> is negative, which will always evaluate to <code>true</code> no matter what the value of <code>j%2</code> is.</p>