Do you know where your variables are? | |
PerlMonks |
Re^4: Bit order in bytesby syphilis (Archbishop) |
on Dec 10, 2013 at 13:38 UTC ( [id://1066428]=note: print w/replies, xml ) | Need Help?? |
Your pack 'v' and pack 'n' arrange the bytes in reverse order - and unpack 'b*' just unpacks them both from the same end ... hence the bytes come out in the reverse order - but each byte is read in ascending bit order, in accordance with the 'b' template spec.
Where you're unpacking the \x12\x34, that's also correct. Both 'b*' and 'B*' read the bytes in the same order, but read those bytes from opposing ends. I don't think there's any nybble-swapping. You've just got one byte that's read either as 01001000 or (reversed) 00010010 (depending upon the template) - and another byte that's being read as either 00101100 or (reversed) 00110100 (depending upon the template). ... I think ... Cheers, Rob
In Section
Seekers of Perl Wisdom
|
|