# Understanding Big and Little Endian Byte Order

Problems with byte order are frustrating, and I want to spare you the grief I experienced. Here's the key:

This is a companion discussion topic for the original entry at http://betterexplained.com/articles/understanding-big-and-little-endian-byte-order/

Great post! Thank you!

how do you write 999 in little endian

Hi Angela, it depends on whether you are using a 2-byte or 4-byte integer. I’ll assume you are using a 4-byte integer because they are more common.

In hex, 999 is 0x03e7. But we need to pad it out to 4 bytes, so it becomes

0x00 00 03 e7

(Broken into 1-byte groups for easier reading). On a little-endian machine, the little end (e7) comes first, so it would be stored as

e7 03 00 00

To double-check, if you plug these numbers into the endian calculator it should give 999 for little-endian.

Hope this helps!

[…] Unicode isnt hard to understand, but it does cover some low-level CS concepts, like byte order. Reading about Unicode is a nice lesson in design tradeoffs and backwards compatibility. […]

[…] Binary files can get confusing. Problems happen when computers have different ways of reading data. There’s something called the “NUXI” or byte-order problem, which happens when 2 computers with different architectures (Mac and PC, for example) try to transfer binary data (I have an article on this that is being ported). Text data is unambiguous. […]

This is really really helpful! Big Thanks!

In Byte Example you say that 00100010 is 0x12 or dec. 18. Is that true?

Whoops, that was a typo – thanks! It should be:

0x12 = binary 0001 0010 = decimal 18

Putting the space helps make it more clear, I’ll make the change now. Appreciate the comment.

thanks a million…a superb explanation about byte ordering…
mr. jakob: there is no typo… its right in doc. as 00010010(0x12) and 18(dec)…

Hi Shekhar, I’m glad you found it useful. Jakob actually caught the typo, I fixed up the original article

Thank you boss… just when i thought that Endianess is a complete waste in the world of Computer arithmatics!!!.. you proved it works…

Hi Sumeash, always happy to help!

i want to know about the coding … how can we change the number present in big endian to little endian and vice-versa

How will following structure look in big-endian and little-endian systems?
struct STRUCT {
unsigned int a:12;
unsigned int b:10;
unsigned int c:10;
};
struct STRUCT myStruct= {0xFED, 0x345, 0x3AB};

Was so very educative. Now I think i can go easy with my programming.

@emile: I’ll have to take a closer look at that one and remember how padded items are laid out :).

@Giridhar: Thanks, glad you liked it.

Awesome post!
thank you

Thanks Yogesh!