Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^5: sprintf %X endianness

by BrowserUk (Patriarch)
on May 14, 2013 at 23:23 UTC ( [id://1033578]=note: print w/replies, xml ) Need Help??


in reply to Re^4: sprintf %X endianness
in thread sprintf %X endianness

*sigh* look at the op, 00021401 is the thing

*sign* Is what "thing"?

Cos in the OP you wrote:"00021401", but in this post you wrote: 00204110 twice. Which should I take as being your requirement?

IF you are now saying that the OP is what you want, then apply yourself, because what I posted in my first response is all you need:

$raw = "\1\24\2\0";; $local = unpack 'L>', $raw;; printf "%08x\n", $local;; 01140200 $local = unpack 'L<', $raw;; printf "%08x\n", $local;; 00021401

And yes, that last pair of statements will work regardless of the platform it is run on.


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.

Replies are listed 'Best First'.
Re^6: sprintf %X endianness
by Anonymous Monk on May 15, 2013 at 02:01 UTC

    *sign* Is what "thing"? Cos in the OP you wrote:"00021401", but in this post you wrote: 00204110 twice. Which should I take as being your requirement?

    I laid out my question in the OP. You ignored it, and then I typoed. I don't have a different machine to test if sprintf %x does the same thing on all machines.

      You ignored it,

      I did not ignore it. I used an example that more clearly demonstrates the process.

      and then I typoed.

      How am I supposed to distinguish which is the typo?


      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.

        I did not ignore it. I used an example that more clearly demonstrates the process.

        Well, I kind of asked a yes/or no question, and then I got lost in your answer.

        On third look just use it and the code will do the right thing. seems to answer that sprintf %x will return the same string on all machines

        How am I supposed to distinguish which is the typo?

        I don't think you are, I kind of think I pointed out what I wanted when I when I realized I made the typo

        Thanks

Log In?
Username:
Password:

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

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

    No recent polls found