On Wednesday, June 20, 2001, at 10:17 AM, Ken Williams wrote:
> Let me first issue the caveat that I have very little experience with bit
> manipulation, so this may be a dumb question.
>
> Consider the following one-liners:
>
> % perl -MConfig -le 'print $Config{byteorder}'
> 4321
> % perl -le 'print join(" ", map { sprintf "%#02x", $_ } \
> -> unpack("C*",pack("L",0x12345678)))'
> 0x12 0x34 0x56 0x78
>
> Those are the two methods `perldoc -f pack` suggests for finding out
> whether a machine is big-endian or little-endian. However, according to
> that page, the first output indicates big-endian, but the second output
> indicates little-endian.
>
> Anyone know why this is happening, and what the real answer is?
I believe the second results does shows big-endian order, as the 0x12 are
the highest order bits. It might be more clear if you used 0x87654321 as
the value, and then you would get 0x87 0x65 0x43 0x21.
--------------------------------------------------------------------------
Edward Moy
Apple Computer, Inc.
[EMAIL PROTECTED]
(This message is from me as a reader of this list, and not a statement
from Apple.)