code: static protected int getPadBits(
          int bitString)
      {
          int val;
  
          if (bitString == 0)
          {
              return 7;
          }
  
          if (bitString > 255)
          {
              val = ((bitString >> 8) & 0xFF);
          }
          else
          {
              val = (bitString & 0xFF);
          }
  
          int bits = 1;
  
          while (((val <<= 1) & 0xFF) != 0)
          {
              bits++;
          }
  
          return 8 - bits;
      }
docs: return the correct number of pad bits for a bit string defined in
  a 16 bit constant