in reply to What is this warning? 'Character in ''c'' format wrapped at ...'

'c' as a pack template is related to signed characters, range -128 to 127. 'C' is the same for unsigned characters, range 0 to 255. Your hex number is 220, which is not in range for the signed numbers...

So your unsigned number is wrapped so it fits into a signed bytes, completely in agreement with the rules of 2's complement. The lower 8 bits are the same, but the additional higher bits are thusly chosen so the resulting number is in range: that number is -36.

print unpack 'c', pack 'C', 220;

Don't use the 'c' template if you don't plan on using signed numbers. Use 'C'.

  • Comment on Re: What is this warning? 'Character in ''c'' format wrapped at ...'
  • Download Code