Difference between revisions of "Little endian"

From AMule Project FAQ
Jump to: navigation, search
 
 
(3 intermediate revisions by 2 users not shown)
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.
  
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.
+
Little [[endian]] tells us to place first the which whose numbers have less weight in the total number. That is FE, since FE here represents 254, while FF represents 65280.
  
 
So, physically in memory we would have:
 
So, physically in memory we would have:
Line 27: Line 27:
 
== Uses ==
 
== Uses ==
  
This [[endian]]ness is used (amongst others) in machines.
+
This [[endian]]ness is used (amongst others) in [http://www.intel.com x86], in [http://www.x86-64.org AMD64] and in [http://h18002.www1.hp.com/alphaserver/vax VAX] machines.
  
 
== Notes ==
 
== Notes ==
  
 
To understand better the little [[endian]] concept it is helpful to compare it to the [[big endian]] concept.
 
To understand better the little [[endian]] concept it is helpful to compare it to the [[big endian]] concept.

Latest revision as of 12:49, 4 March 2006

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 FE, 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.