in reply to Detecting machine Endian-ness
That is close to a test I've used:
Note that the "I" format can result in more than 4 bytes on some platforms. - tye (but my friends call me "Tye")my $o= pack( 'I', 0x04030201 ); if( substr($o,-4) eq "\04\03\02\01" ) { return "big"; } elsif( substr($o,0,4) eq "\01\02\03\04" ) { return "little"; } else { die "Strange endian"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: Detecting machine Endian-ness
by LunaticLeo (Scribe) on Aug 07, 2001 at 02:58 UTC | |
by tye (Sage) on Aug 07, 2001 at 07:48 UTC |