[Tutor] little/big endian was Re: what is 'doubleword alignment'?

Steven D'Aprano steve at pearwood.info
Thu Jul 21 14:56:45 CEST 2011


Dave Angel wrote:

> Little-endian is the method used by the Intel processor (such as the 
> Pentium).  Big-endian is the system used by most network protocols, as 
> well as the 68000 and many other processors.

There used to be mainframes with various forms of middle-endian layouts. 
Fortunately they are no longer around.

http://www.retrologic.com/jargon/M/middle-endian.html


> For our purposes, it's the ordering of the bytes within a 16 or 32 bit 
> number.  Little-endian puts the least significant byte first, while 
> big-endian puts the most significant byte first.

In this context, least significant and most significant may need explaining.

In decimal numbers, we write one hundred and twenty-three as 123. The 1 
is most significant, because it represents 1 HUNDRED rather than 1 UNIT. 
And similarly the 3 is least significant. So numbers using Arabic 
numerals are big-endian.

The same applies for computer integers. 123 written in hexadecimal is 
7B, which of course is big-endian just like decimal. But when storing 
this number in memory, we have a choice: we can store it in big-endian 
format, just like we write it: 7B, where the 7 is the "left-most" 
(lowest address) number. Or we can store it in little-endian format, B7, 
where the 7 has the higher address, and read from right-to-left.

And of course, bytes themselves can be either little-endian or 
big-endian, *independently* of byte ordering within larger units.

http://en.wikipedia.org/wiki/Endianness
http://en.wikipedia.org/wiki/Bit_numbering



-- 
Steven


More information about the Tutor mailing list