title: Subtracting 8-bit integers in Python
body: <p>I'm trying to use Python to calculate a checksum by repeatedly <strong>subtracting a series of 8 bit values.</strong> However, I don't know how to do this in Python.</p>
  
  <hr>
  
  <p><strong>In context:</strong>
  I have the following C code I'm trying to convert to Python:</p>
  
  <pre class="lang-c prettyprint-override"><code>#define uint8_t unsigned char
  static uint8_t fix_header(uint8_t *header) {
      uint8_t sum = 0;
      uint8_t count = 0xbc - 0xa0;
  
      /* complement check of 0xa0 - 0xbc */
      header = header + 0xa0;
  
      while (count-- &gt; 0) {
          sum = sum - *header++;
      }
  
      sum = (sum - 0x19);
  
      return sum;
  </code></pre>
  
  <p>It's the <a href="http://nocash.emubase.de/gbatek.htm#gbacartridgeheader" rel="nofollow">checksum code for GBA game headers</a>. I'm having trouble replicating this in Python. I can do everything except <code>sum = sum - *header++;</code>, since (as far as I know), Python has no limit on how large a variable can be. I've tried this using Python's <code>int</code> but this gives incorrect checksums. From what I can see the 8-bit limit is doing something special I don't understand or know about.</p>
  
  <p>Your help is appreciated!</p>