title: Cast a 10 bit unsigned integer to a signed integer in python
body: <p>I have a list of numbers in the range 0-1023. I would like to convert them to integers such that 1023 maps to -1, 1022 maps to -2 etc.. while 0, 1, 2, ....511 remain unchanged.</p>
  
  <p>I came up with a simple:</p>
  
  <pre><code>def convert(x):
      return (x - 2**9) % 2**10 - 2**9
  </code></pre>
  
  <p>is there a better way?</p>