From: jackc@vermont.mti.sgi.com (Jack Choquette)
Newsgroups: comp.arch
Subject: A theory for Big & Little Endian's origin
Date: 8 Jan 93 00:00:42 GMT
Organization: Silicon Graphics, Inc.
NNTP-Posting-Host: vermont.mti.sgi.com


To me it seems like different endianess came about because of the way
humans like to see things listed out.  When humans make a list, they
like to make and read it top to bottom:
		0  ******
		1  ******
		2  ******
		 etc.


For reasons explained in previous posts, humans (who read left to right)
like to read the most significant digit first.  So they place the most
significant digit on the left:
		1,0562

When you number the digits, you could number them in the same order
that you read them:
		digit #		0  1  2  3  4
		digit value	1, 0  5  6  2

This has the problem that as numbers get bigger, their digit numbers 
change.  
		digit #		0  1  2  3  4  5
		digit value	7  3, 1  9  3  1

Also when you are comparing numbers of different sizes, their
respective digit # doesn't correspond to the digits value.  In the
two examples above, digit #0 in 1 thousand for one but it's 
70 thousand for the other.

So it makes more sense, mathematically at least, to reverse number
numbers and zero fill the number that are not there.
		digit #		5  4  3  2  1  0
		digit value	0  1, 0  5  6  2
		digit value	7  1, 0  5  6  2

Now we come to representing numbers in computers.  Being mathematically
inclined, computer engineers represent numbers by putting the least
significant bit in the lowest numbered (and addressible) spot.  Being
human, when they print out the number they print out the most significant
bit first:
		digit #/address		7  6  5  4  3  2  1  0
		digit value (bin)	0  1  0  0  1  1  1  0   =   78 dec

As computer engineers build computers, they want to be able to address
chunks of bits instead of individual bits.  They choose a chunk size of
8 bits.  Why 8, because it is the only power of 2 number that gives you
enough bits to represent the entire alphabet.

Now they want to list out the contents of their memory.  Being human,
they do it top to bottom, in ascending order so you can read the 
characters and text stored there:
	     Location	Bit Value  Ascii
		0	01001110     H      {I know these are not the correct}
		1	10100010     E      {  ascii values}
		2	00010111     L
		3	00010111     L
		4	11110111     0
So text and programs are stored in order of ascending memory locations.

But what happens when you want to specify a number that is 16bits wide
and store it at location 1?  Obviously you divide up the number into
two 8bit chunks and store it in location 1, and the location
following, location 2.

Where does the most significant 8bits (byte) go?  If you're human, you
feel the most significant byte should go first, so you put it in
location 1
	     Location	Value
		1	11111111
		2	00000000

	Number:  11111111   00000000
	Bit #	 76543210   76543210
	Byte #	    1          2

However, if you're mathematically inclined, you want the numbering of the
bytes to be in reverse order for the same reason the numbering of the
bits is in reverse order:
	     Location	Value
		1	00000000
		2	11111111

	Number:  11111111   00000000
	Bit #	 76543210   76543210
	Byte #	    2          1

In the first case you get Big Endian, in the second you get Little
Endian.


I think it's interesting to note that within a byte, the order is
always Little Endian.  This is because when computers where developed,
the designers wanted bit numbers listed left to right but numbered
left to right:
		digit #/address		7  6  5  4  3  2  1  0
		digit value (bin)	0  1  0  0  1  1  1  0   =   78 dec

So in effect Big Endian is inconsistent when dealing with binary
numbers.  However it has the advantage of being seemless when memory
values are printed out.  When memory is printed out, the bytes are
printed out lowest to highest (because that's the way text and
programs are stored) but the bits within a byte are printed highest to
lowest:

   Printout:
	01001110 10100010

   Translates to 
	Number:  01001110   10100010
	Bit #	 76543210   76543210
	Byte #	    1          2

In order to be consistent numerically, Big Endian bytes should be
stored and printed in ascending bit values.

The flip side is that Little Endian text and programs should be stored
and printed out in descending memory locations so that text and
programs are stored with the same ordering as binary numbers.



/jack