title: How that helps to convert
body: <p>There is not my front-end code that is converting X from int to short and save it in a binary stream </p>
  
  <pre><code>       write(x &amp; 0xFF)
         write((x &amp; 0xFFFF) &gt;&gt; 8 )
  </code></pre>
  
  <p><em>(I am C++ back-end dev and not sure what the language this is.. looks like JS but there is no Int data type as I know.)</em></p>
  
  <p>I am don't understand how <code>x &amp; 0xFF</code> and <code>(x &amp; 0xFFFF) &gt;&gt; 8</code> helps to convert int to short. Can you explain?</p>