PythonTip >> 博文 >> python

小端序(little-endian)和大端序(big-endian)

zihua 2014-01-25 15:01:04 点击: 972 | 收藏


Endianness=端序=尾序=字节顺序

Little-endian=小端序=低位字节存在低内存地址处,(x86,MOS Technology 6502,Z80,VAX,PDP-11等处理器)

Register:0A0B0C0D   Memory: a存0D a+1存0C a+2存0B a+3存0A

Big-endian=大端序=反之,(Motorola 6800,Motorola 68000,PowerPC 970,System/370,SPARC(除V9外)等处理器)

Register:0A0B0C0D   Memory: a存0A a+1存0B a+2存0C a+3存0D

C/C++ 查看端序:

int n = 1;

// little endian if true

if(*(char *)&n == 1) {...}

Python 查看端序

>>> import sys

>>> sys.byteorder

'little' 或者 'big'

原文链接:http://www.tuicool.com/articles/fEbeA3Y

作者:zihua | 分类: python | 标签: python | 阅读: 972 | 发布于: 2014-01-25 15时 |