> -----Original Message-----
> From: Stefan Oswald [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 21, 2001 8:53 AM
> To: '[EMAIL PROTECTED]'
> Subject: question concerning signed char
> 
> 
> 
> I´ve read the term "signed char" in a script that i want to analyze. I
> checked the cookbook and cpan and i still have no clue, what 
> that could
> mean.

a signed char is an integer data type with a size of one byte. 7 bits are
magnitude and 1 bit for sign (twos-complement). The range is -128 to +127.
(An unsigned char uses all 8 bits for magnitude, so the range is 0 to +255.)

unpack() needs to know whether you want to treat the byte as signed or
unsigned when converted to a perl numeric value:

   $byte = chr(0xFF);          # create a byte of all 1's
   print unpack('c', $byte);   # prints -1 (signed char)
   print unapck('C', $byte);   # prints 255 (unsigned char)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to