title: Simulating C#'s sbyte (8 bit signed integer) casting in Python
body: <p>In C#, I can cast things to 8bit signed ints like so:</p>
  
  <pre><code>(sbyte)arg1;
  </code></pre>
  
  <p>which when <code>arg1 = 2</code>, the cast returns 2 also. However, obviously casting <code>128</code> will return <code>-128</code>. More specifically casting <code>251</code> will return <code>-5</code>.</p>
  
  <p>What's the best way to emulate this behavior?</p>
  
  <p>Edit: Found a duplicate question: <a href="https://stackoverflow.com/questions/385572/need-help-typecasting-in-python">Typecasting in Python</a> </p>
  
  <pre><code>s8 = (i + 2**7) % 2**8 - 2**7      // convert to signed 8-bit
  </code></pre>