Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: Bit order in bytes

by syphilis (Archbishop)
on Dec 10, 2013 at 13:38 UTC ( [id://1066428]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Bit order in bytes
in thread Bit order in bytes

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

Replies are listed 'Best First'.
Re^5: Bit order in bytes
by BrowserUk (Patriarch) on Dec 10, 2013 at 14:15 UTC

    I did say "apparent nybble swapping" :)

    Its one of those things that has caused me to look twice on many occasions, but never caused me enough concern nor affected anything I was doing, to require investigation.

    Now looking at it, it becomes clear that it just comes down to the fact that when we right "\x12",

    we write the high nybble 0x1 before the low nybble 0x2.

    Thus, when it is displayed with 'b', lsb -> msb, the digits appear to swap places.

    Another red-herring laid bare :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1066428]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-26 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found