[Pdx-pm] PowerPC and little-endian

jerry gay jerry.gay at gmail.com
Tue Feb 28 23:11:40 PST 2006


On 2/28/06, Eric Wilhelm <scratchcomputing at gmail.com> wrote:
> Hi all,
>
> Since I'm in the minority of non-mac owners around here, maybe you all
> can fill me in on this whole dual-mode software-switched rumor about
> the powerpc being able to run in either big or little endian mode.  I
> need to unpack some floats and doubles in a cross-platform way and yeah
> I could do that in pure perl with some of the portable pack/unpack
> commands and some byte twiddling, but that's going to be slow and so
> I'll then end up maintaining two pieces of code, so I was thinking I
> could compile perl to run in little-endian mode.
>
from `perldoc -f pack`:

    pack TEMPLATE,LIST
    [snip]
                n   An unsigned short in "network" (big-endian) order.
                N   An unsigned long in "network" (big-endian) order.
                v   An unsigned short in "VAX" (little-endian) order.
                V   An unsigned long in "VAX" (little-endian) order.
                      (These 'shorts' and 'longs' are _exactly_ 16 bits and
                       _exactly_ 32 bits, respectively.)

maybe that will suffice? it will pack/unpack in the respective byte
order on any platform, no byte twiddling needed.
~jerry


More information about the Pdx-pm-list mailing list