Jul
02

Detect CPU Endian-ness

By celso

To detect a CPU’s endian architecture, use either one of the variables set like so:


$is_big_endian = unpack("h*", pack("s", 1)) =~ /01/;
$is_little_endian = unpack("h*", pack("s", 1)) =~ /^1/;

Found in Perlmonks

Categories : Notes, Perl

Leave a Comment

You must be logged in to post a comment.