title: Splitting a 16 bit int into two 8 bit ints in python
body: <p>I have to convert a given 16 bit integer into two 8 bit integers, which are then taken and used as output, where they are headed takes the two 8 bit integers and recombines them as 16 bit input (unfortunately out of my control).  My solution works, but feels unclean.  For the coarse number I am bit shifting the original number, and for the fine number I am looking at it modulo 256.</p>
  
  <p>So should I be doing floor division for the coarse number, or should I be taking the lowest 8 bits for the fine number (and if so how?)?</p>
  
  <p>Or am I crazy and using two different methods to split the number is not a problem?</p>
  
  <pre><code>def convert(x):
      ''' convert 16 bit int x into two 8 bit ints, coarse and fine.
  
      '''
      c = x &gt;&gt; 8  # The value of x shifted 8 bits to the right, creating coarse.
      f = x % 256  # The remainder of x / 256, creating fine.
      return c, f
  </code></pre>