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

给你一囗甜甜゛ 提交于 2019-11-30 12:11:11
perl -MConfig -e 'print "$Config{byteorder}\n";'

See Perl documentation.

Sean

I guess you could do:

$big_endian = pack("L", 1) eq pack("N", 1);

This might fail if your system has a nonstandard (neither big-endian nor little-endian) byte ordering (eg PDP-11).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!