*UPDATE* Apparently the only one coming in erroneous (in Perl) is the transformation matrix... the array of 16 doubles.

What type of system is the data being written on? (And what type of system are you unpacking it on?)

My guess is that they are different types. Whilst the 'N' format will ensure that an integer packed on a big-endian system will be correctly unpacked on a little-endian box, there is no such guarentee for the 'd' (or 'f') formats. From perlfunc:pack:

f A single-precision float in the native format. d A double-precision float in the native format.

Even if both source and destination use the same floating point representation, the physical layout of the bytes that make up that representation will vary with endianess.

If this assumption is correct, then the very minimum you would need to do is to re-order the bytes to compensate. This can be done by unpacking your doubles to 8-byte strings and using reverse or similar methods to re-order the bytes before using unpack to decode them. But that will only work if they both use the same basic FP representation.

You'll need to find out what FP reps are used at both ends before progressing.

See Re: Value packed as 'D', how to unpack not using 'D'? and Re: graphic a segy file for related problems.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

In reply to Re: C Struct Data Problem by BrowserUk
in thread C Struct Data Problem by heroin_bob

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.