title: Signed and unsigned, and how bit extension works in C
body: <pre><code>unsigned short s;
  s = 0xffff;
  int i = s;
  </code></pre>
  
  <p>How does the extension work here? 2 larger order bytes are added, but I'm confused whether 1's or 0's are extended there. This is probably platform dependent so let's focus on what Unix does. Would the two bigger order bytes of the int be filled with 1's or 0's, and why?</p>
  
  <p>Basically, does the computer know that <code>s</code> is unsigned, and correctly assign 0's to the higher order bits of the int? So <code>i</code> is now <code>0x0000ffff</code>? Or since <code>ints</code> are default signed in unix does it take the signed bit from <code>s</code> (a 1) and copy that to the higher order bytes?</p>