Convert binary data to signed integer
<p>I read a binary file and get an array with characters. When converting two bytes to an integer I do <code>256*ord(p1) + ord(p0)</code>. It works fine for positive integers but when I get a negative number it doesn't work. I know there is something with the first bit in the most significant byte but with no success. </p>

<p>I also understand there is something called <code>struct</code> and after reading I ended up with the following code</p>

<pre><code>import struct

p1 = chr(231)
p0 = chr(174)

a = struct.unpack('h',p0+p1)

print str(a)
</code></pre>

<p><code>a</code> becomes -6226 and if I swap <code>p0</code> and <code>p1</code> I get -20761. </p>

<p><code>a</code> should have been -2</p>
