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

Not sure about your statement on swapping but I cannot see any. hex 12 is decimal 18 = 16 + 2 is binary 00010010 and hex 34 is decimal 52 is binary 00110100.

print unpack 'b*', "\x12\x34";; 01001000 00101100 18 52 print unpack 'B*', "\x12\x34";; 00010010 00110100 18 52

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

    Nybbles == 4-bits, so looking at the byte values in decimal doesn't show it.

    Look at the patterns of the nybbles (in hex):

    ## 'b' lists bits lsb->msb print unpack 'b*', "\x12\x34";; 1248 1248 1248 1248 0100 1000 0010 1100 2 1 4 3 ## 'B' lists bits msb <- lsb print unpack 'B*', "\x12\x34";; 8421 8421 8421 8421 0001 0010 0011 0100 1 2 3 4

    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.