title: How to tell if a 32 bit int can fit in a 16 bit short
body: <p>Using only:</p>
  
  <pre><code>! ~ &amp; ^ | + &lt;&lt; &gt;&gt;
  </code></pre>
  
  <p>I need to find out if a signed 32 bit integer can be represented as  a 16 bit, two's complement integer.</p>
  
  <p>My first thoughts were to separate the MSB 16 bits and the LSB 16 bits and then use a mask to and the last 16 bits so if its not zero, it wont be able to be represented and then use that number to check the MSB bits.</p>
  
  <p>An example of the function I need to write is: fitsInShort(33000) = 0 (cant be represented) and fitsInShort(-32768) = 1 (can be represented)</p>