title: C Convert a Short Int to Unsigned Short
body: <p>A short int in C contains 16 bits and the first bit represents whether or not the value is negative or positive. I have a C program that is as follows:</p>
  
  <pre><code>int main() {
      short int v;
      unsigned short int uv;
      v = -20000;
      uv = v;
      printf("\nuv = %hu\n", uv);
      return 0;
  }
  </code></pre>
  
  <p>Since the value of <strong>v</strong> is negative I know the first bit of the variable is a 1. So I expect the output of the program to equal <strong>uv = 52,768</strong> b/c <strong>20,000 + (2^15) = 52,768</strong>.</p>
  
  <p>Instead I am getting <strong>uv = 45536</strong> as the output. What part of my logic is incorrect?</p>