Actually, I don't need to know this, but here is the code for detecting endianness for normal big and little 32bit machines. Extensions for 64bit welcome; but this works for me on Linux-IA32 and Solaris2.6-UltraSparc .
@b = unpack('CCCC', pack('I', 0x04030201)); if ($b[0] == 4 and $b[1] == 3 and $b[2] == 2 and $b[3] == 1 ) { print "big-endian\n"; } elsif ($b[0] == 1 and $b[1] == 2 and $b[2] == 3 and $b[3] == 4 ) { print "little-endian\n"; } else { print "funky-endian\n"; }
In reply to Detecting machine Endian-ness by LunaticLeo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |