Big endian

From AMule Project FAQ
Jump to: navigation, search

Introduction to endianness

Having read the endianness article, you might already have an idea of what this is for.

The endianess defines the bytes' order in physical memory.

Definition

When you must store a two-bytes (or larger) value in memory, you can either store the first byte(s) in the first place or the second byte(s) in the first place.

Big endian defines that the first bytes will go first.

Example

An example of a two-bytes number is 65534. This number requires two bytes to be stored in memory. The decimal number 65534 is represented, in hexadecimal, as FFFE (or 0xFFFE). Here we can see the two byes: FF and FE.

We can decide wether we want to palce the FF byte first in memory or the FE byte first.

Big endian tells us to place first the which whose numbers have more weight in the total number. That is FF, since FF here represents 65280, while FE represents 254.

So, physically in memory we would have:

                    _________________________
Memory Graph:      |_____FF_____|_____FE_____|
Memory Possitions:     000001       000002

Uses

This endianness is used (amongst others) in SPARC, PowerPC and System/360 machines.

Notes

To understand better the big endian concept it is helpful to compare it to the little endian concept.