# Little vs Big Endian

• 09-10-2010
Wokzombie
Little vs Big Endian
I have been searching for info on Big Endian v. Little Endian, but the information I have found so far has has mostly been pretty vague.

I know with big endian a single byte will have 8 bits from right to left (high to low) and little endian has 8 bits from left to right (low to high) in a single byte.

But does this extend to multiple bytes as wel? As in, will 5 big endian bytes go from right to left and 5 little endian bytes go from left to right the same as the previous example?

Or am I looking at this principle completely the wrong way?
• 09-10-2010
brewbuck
It has to do with the arrangement of multi-byte quantities and has nothing at all to do with order of bits in a byte. Endianness has to do with how the components of quantities are addressed, and since bits are not addressable, endianness does not apply to them.

In a little-endian representation, the least significant parts of a quantity occur at the lowest memory addresses, and vice versa for big-endian.
• 09-10-2010
Wokzombie
It is quite late over here, but would you mind explaining yourself a bit further?

Or if you know any good reading material, I would love it if you could point me in the right direction.
• 09-11-2010
SMurf
Croikey.

Let's take a number, say 16,777,215. In hex you would write this on paper as 00FFFFFF (extending to 32 bits for simplicity's sake).

Now for how this would appear in memory/registers in different endians...
Little endian (e.g. Intel CPUs):-
Code:

```Offset    00 01 02 03 Data      FF FF FF 00```
Big endian (e.g. Motorola CPUs):-
Code:

```Offset    00 01 02 03 Data      00 FF FF FF```
In little endian, the least significant bits of a multi-byte integer are stored at the lowest address in memory.
In big endian, the most significant bits of a multi-byte integer are stored at the lowest address in memory.

Comprendez?
• 09-11-2010
SMurf
In addition, individual bytes are always in MSB order, regradless of applied endian.
So for 0x12345678:-
Code:

```Little endian:- Offset    00 01 02 03 Data      78 56 34 12 Big endian:- Offset    00 01 02 03 Data      12 34 56 78```
• 09-11-2010
BMJ
Endianness affects the byte ordering of words. The way that bits are arranged within a byte is the same on all architectures.
• 09-11-2010
Elysia
Quote:

Originally Posted by SMurf
In little endian, the least significant bits of a multi-byte integer are stored at the lowest address in memory.
In big endian, the most significant bits of a multi-byte integer are stored at the lowest address in memory.

Perhaps that is better to say least and most significant byte, since that's all that's really changing.
• 09-11-2010
SMurf
Conceded. I'm still worried that I'll end up a teacher of this stuff. :(