title: How in swift to convert Int16 to two UInt8 Bytes
body: <p>I have some binary data that encodes a two byte value as a signed integer.  </p>
  
  <pre><code>bytes[1] = 255  // 0xFF
  bytes[2] = 251  // 0xF1
  </code></pre>
  
  <h2>Decoding</h2>
  
  <p>This is fairly easy - I can extract an <code>Int16</code> value from these bytes with: </p>
  
  <pre><code>Int16(bytes[1]) &lt;&lt; 8 | Int16(bytes[2])
  </code></pre>
  
  <h2>Encoding</h2>
  
  <p>This is where I'm running into issues.  Most of my data spec called for <code>UInt</code> and that is easy but I'm having trouble extracting the two bytes that make up an <code>Int16</code></p>
  
  <pre><code>let nv : Int16 = -15
  UInt8(nv &gt;&gt; 8) // fail
  UInt8(nv)      // fail
  </code></pre>
  
  <h2>Question</h2>
  
  <p>How would I extract the two bytes that make up an <code>Int16</code> value</p>