in reply to first 5 bits and last 3 bits

The "first 5 bits" of a number really depend on the storage format.

For example as a 32 bit integer, 129 is represented as 00000000000000000000000010000001, the first 5 bits of which are all zero.

If that's not what you want, consider converting the number to the string 10000001 by using sprintf and then use substr to extract what you want.

Replies are listed 'Best First'.
Re^2: first 5 bits and last 3 bits
by pashanoid (Scribe) on Jul 26, 2011 at 12:55 UTC
    It's 8 bits
      Not just how many bits, but whether it is big or little-endian.