Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I'm trying to fix a bug in Audio::OSC, where values are packed/unpacked incorrectly on some platforms and I've run into a problem I can't really solve:

According to the OSC Spec examples, a float value of 440.0 should be encoded as 43 dc 00 00. Using pack('f', 440.0'), I get these results:

  • Mac: 43 dc 00 00 - correct according to spec.
  • PC: 00 00 43 dc - incorrect.

A user suggested the somewhat unsightly combination pack("N", unpack("l", pack("f", 440.0))), but that yielded

  • Mac: 43 dc 00 00 - still correct
  • PC: dc 43 00 00 - still incorrect, but differently

Can somebody help me to come up with a good and fast solution for this? Even if it only works on PCs, it's okay -- I can check the endian-ness on startup and make aliases for the correct function to use. The main point is that it should be correct and fast.


In reply to Stumped by a pack/unpack problem by crenz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found