Byte Ordering: Big Endian And Little Endian

December 4, 2010 at 9:41 AM (Technical Articles)

Byte Ordering:

We almost every one know about byte ordering in the underlying architecture . In which order each bit of a data stored in memory ? does tell byte ordering. Of course it is different for different architectures. It become very awkward when a programmer do develop for some other architecture which is not the same as the architecture on which he is developing . It will be something like A right-handed person trying to write with his left hand.

Today I am not going to explain what exactly mean by byte ordering. Instead I am providing a simple definition and two images . some one said that One image is equivalent to Thousand words .  And also some interesting facts on byte ordering.

Endianness: It is the ordering of individually addressable sub-units (words, bytes, or even bits) within a longer data word stored in external memory. (wiki definition ).

Two Types Of Byte Ordering:

1> Big Endian: Underlying architecture stores the least significant byte in the lowest address.

2> Little Endian: Underlying architecture stores the least  significant byte in the highest address.

How they fit in memory?

For better understanding: I am giving an example of C Structure.

Try to understand the image. See the memory layout of a C Structure . Mainly look that character array and one more char variable in memory.

 int     a;     //0x1112_1314    word
 double    b;    //0x2122_2324_2526_2728    double word
 char  *c;    //0x3132_3334    Word
 char    d[7];    // ‘A’ ‘B’ ‘C’ ‘D’ ‘E’ ‘F’   ‘G’     byte array
 short    e;    // 0x5152
 int    f;    //0x6162_6364

Memory Layout :



See the  memory as a series of array locations:


Alternate view of Memory Map

Alternate view of Memory Map

(If Image is not visible clearly, please write click on the image and open it in new tab)

Some interesting facts on Endianess:
1>    Our entire Internet is in big endian format. It means almost all the protocols, APIs are in big endian . And hence writing internet programs on PC makes very awkward. In Windows WinSock provides htoi ( host to internet ) and itoh ( internet to host ) APIs for  necessary conversions.

2>    Java stores its byte code in big endian format , even though the underlying architecture is little endian, a compiled version of a java program, has a byte code in big endian format.

3>    Most of the architectures and network protocols (TCP/IP & UDP mainly ) are big endian . Visit this site for more details :  Please refer table 1 & table 2 in this link.

4>    Even though most of the architecture are in Big endian, why Intel switched to little endian? By the time Intel grown up, most of the network protocols and many other architectures were developed in big endian format. But still intel started its processor manufacturing in little endian. Are there any specific technical reason behind this? I am in search of answer . Help me !!! 🙂



  1. Nivedita Angadi said,

    Hi Sadu,
    Really wonderful fact about Endian..!! Byte ordering..!! Your blogs are easy of getting fascinating facts ..!!
    Thanks again..!!

  2. sheetal gotmare said,

    hi sadu,

    Your article is great and your question that “started its processor manufacturing in little endian. Are there any specific technical reason behind this??” inspires to develop curiosity. I think worlds 90% peoples using languages written from left to right like English and 10 or lesser peoples uses language like Arabic and such which start from right to left.
    The conflict between the memory arrangements of binary data and text is intrinsic to the nature of the little-endian convention, but is a conflict only for languages written left-to-right (such as Indo-European languages like English(Roman), French(Roman), Russian(Cyrillic) and Hindi (Devanagari)). For right-to-left languages such as Arabic or Hebrew, there is no conflict of text with binary, and the preferred display in both cases would be with addresses increasing to the left. (On the other hand, right-to-left languages have a complementary intrinsic conflict in the big-endian system.
    This might be a technical and business reason inter manufacture the processor in little endian.

    • SAN said,

      hey SA..
      blog is really good. ur revolving arround some performance issues with memory and processor[last blog]. fiber optical is the next technology which will definitely bring more speed into the technolgy with best performance. while reading ur blog go-ogled out about endian felt interesting. a novice can easily get this concept in link “”. good WORK.
      “BETTER LATE THAN NEVER” for delay in reading blog

    • Sadanand Teggi said,

      @ San:
      Thanks for the useful link.

  3. website said,

    Hi, after reading this amazing article i am as well cheerful
    to share my knowledge here with mates.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: