Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: converting artibrary binary data to numeric values

by johngg (Abbot)
on Sep 30, 2012 at 21:57 UTC ( #996547=note: print w/ replies, xml ) Need Help??


in reply to converting artibrary binary data to numeric values

This might help you visualise what is happening when packing and unpacking big- and little-endian values, as mentioned in Corion's reply.

$ perl -E ' > say q{Big-endian}; > $BEflag = pack q{N}, 1; > say unpack q{B*}, $BEflag; > say sprintf q{0x%02x}, ord $_ for split m{}, $BEflag; > say unpack q{N}, $BEflag; > say q{Little-endian}; > $LEflag = pack q{V}, 1; > say unpack q{B*}, $LEflag; > say sprintf q{0x%02x}, ord $_ for split m{}, $LEflag; > say unpack q{V}, $LEflag;' Big-endian 00000000000000000000000000000001 0x00 0x00 0x00 0x01 1 Little-endian 00000001000000000000000000000000 0x01 0x00 0x00 0x00 1 $

I hope this is helpful.

Cheers,

JohnGG


Comment on Re: converting artibrary binary data to numeric values
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-10-23 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls