Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

endianness - Finding if the system is little endian or big endian with perl

Is there an option to find if my system is little endian byte order or big endian byte order using Perl?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
perl -MConfig -e 'print "$Config{byteorder}
";'

See Perl documentation.

If the first byte of the output string is 1, you can assume (with moderate safety) that it is little-endian. If it is 4 or 8, you can assume big-endian.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...