SPUG: 24-bit signed int unpacking?
ericj at cubesearch.com
Fri Oct 1 02:17:35 CDT 2004
I'm trying to use unpack to convert binary 24-bit ints into native perl
For example (in hex):
I'd like to convert:
"\x24\x00\x00" => 66
"\xf9\xff\xff" => -7
I COULD just tack on 0x00 or 0xFF based on the last byte values, but this
seems really ghetto. Is there a slicker method for conversion?
print unpack('i*', "\xf9\xff\xff"); # Darn, doesn't work...
More information about the spug-list