title: Answer to a practice interview question
body: <p>I'm just going through a bunch of C++ interview questions just to make sure there's nothing obvious that I don't know. So far I haven't found anything that I didn't know already, except this:</p>
  
  <pre><code>long value;
  //some stuff
  value &amp;= 0xFFFF;
  </code></pre>
  
  <p>The question is "what's wrong with this code?" And hints that it's something to do with target architectures.</p>
  
  <p>Unless the answer is just "value isn't initialized", I can't see any problem. As far as I can tell, it's just masking the 2 least significant bytes of the value, and <code>long</code> is guaranteed to be at least 2 bytes, so there's no problem there.</p>
  
  <p>Could it possibly be that <code>long</code> might only be 2 bytes on the target architecture, and you might be losing the sign bit? Or perhaps that the 0xFFFF is an <code>int</code> and <code>int</code> is only 2 bytes?</p>
  
  <p>Thanks in advance.</p>