mjscott2702 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to generate some binary data on an x86 box (i.e little-endian) that emulates generating that data on a Sun box (i.e. big-endian). I can get most of the integer fields (various byte-lengths) to format correctly using pack. However, I have hit a brick-wall for floating point values (float not double).
I think my problem lies here (from the pack documentation): "f A single-precision float in the native format."
My guess is that the key phrase there is native format.
So, is there a way of generating a float in "non-native" format to look like it comes from a big-endian CPU? I tried simply reversing the bytes, but that didn't work:
reverse pack("f", $floatVal)
Any ideas most welcome!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use pack to create a float in non-native format
by BrowserUk (Patriarch) on Feb 06, 2010 at 18:52 UTC | |
by mjscott2702 (Pilgrim) on Feb 07, 2010 at 09:58 UTC | |
by BrowserUk (Patriarch) on Feb 07, 2010 at 12:26 UTC | |
|
Re: Use pack to create a float in non-native format
by rowdog (Curate) on Feb 07, 2010 at 01:19 UTC | |
by mjscott2702 (Pilgrim) on Feb 07, 2010 at 10:04 UTC |