Difference between revisions of "Little endian"

From AMule Project FAQ
Jump to: navigation, search
m (=Example= typo)
Line 13: Line 13:
 
== Example ==
 
== 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.
+
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 bytes: FF and FE.
  
 
We can decide wether we want to place the FF byte first in memory or the FE byte first.
 
We can decide wether we want to place the FF byte first in memory or the FE byte first.

Revision as of 13:28, 15 March 2005

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.

Little 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 bytes: FF and FE.

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

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

So, physically in memory we would have:

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

Uses

This endianness is used (amongst others) in x86, in AMD64 and in VAX machines.

Notes

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