title: Read 32-bit signed value from an "unsigned" bytestream
body: <p>I want to extract data from a file whoose information is stored in big-endian and <em>always</em> unsigned. How does the <strong>"cast"</strong> from <em>unsigned int</em> to <em>int</em> affect the actual decimal value? Am I correct that the most left bit decides about the whether the value is positive or negative?</p>
  
  <p>I want to parse that file-format with python, and reading and unsigned value is easy:</p>
  
  <pre><code>def toU32(bits):
      return ord(bits[0]) &lt;&lt; 24 | ord(bits[1]) &lt;&lt; 16 | ord(bits[2]) &lt;&lt; 8  | ord(bits[3])
  </code></pre>
  
  <p>but how would the corresponding <em>toS32</em> function look like?</p>
  
  <hr>
  
  <p>Thanks for the info about the <em>struct</em>-module. But I am still interested in the solution about my actual question.</p>