Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I don't work every day with big-endian and little-endian problems and thus I find very difficult to remember which one is what.

Recently I got an interview asking the difference between the two; since I didn't remember I decided to "guess" (50% chance, after all) but I failed.

So, is there any wide known pratical trick to remember what is the difference between big endian and little endian?

share|improve this question
6  
I thin kyou are better off stating what endianess is and saying you can never remember which way round it is so you always google it –  jk. Apr 4 '12 at 11:44
    
I too have problems remembering it and there are too many confusing mnemotechnic tricks. My only reliable help is to cast the endianness spell on google so that I get the Wikipedia article. –  mouviciel Apr 4 '12 at 12:49
2  
Funny coincidence - I only stumbled on this link today, and it's surprisingly relevant commandcenter.blogspot.com/2012/04/byte-order-fallacy.html –  Nevermind Apr 4 '12 at 14:56

5 Answers 5

up vote 10 down vote accepted

I've always thought that it's defined the wrong way, and that's also the tip to remember it. As a non-native English speaker, I see "end" as the opposite of "start" (although obviously "end" can mean either end - the start end, or the end end). Anyway, I just remember that "it's defined the wrong way" :)

  • In big endian, the most significant (biggest) byte is in the start.
  • In little endian, the least significant (littlest) byte is in the start.

Or, referring to bit endianness:

  • 128 64 32 16 8 4 2 1 is big endian, because it ends to the little.
  • 1 2 4 8 16 32 64 128 is little endian, because it ends to the big.

Even though the usual use of the word endianness refers to how bytes are ordered within a word, its generic meaning refers to the ordering of individually addressable sub-components within the representation of a larger data item (as explained in Wikipedia).

share|improve this answer
4  
ahh, but the little-endian lilliputians started (cracked) their eggs at the little end so it is the right way round –  jk. Apr 4 '12 at 11:57
4  
-1: Endian-ness refers to bytes within a word, not bits within a byte. –  kdgregory Apr 4 '12 at 12:29
    
@kdgregory - In the end, bit numbering is impacted within a word. Have you tried bit-field structs accross different endians? I agree that the answer has it wrong, though. –  mouviciel Apr 4 '12 at 12:54
    
@Kdgregory: According to Wikipedia, endianness refers to the ordering of individually addressable sub-components within the representation of a larger data item. That's the generic case. There's also a notion of bit endianness. You're right in that the most common use of endianness refers to how bytes are ordered within a word, and my examples admittedly didn't reflect that. Replaced the first example with the common case. –  Joonas Pulakka Apr 4 '12 at 12:55
2  
@kdgregory: Since when is existence of hardware required to justify CS theoretical notions? But very well: 8051 has bit-addressable registers. Ada language allows specifying the appropriate bit order for data type representation (pdf). Transmission order of bits over a serial medium of course needs to define bit endianness. The fact that the usual use of "endianness" refers to a special case (bytes in words) doesn't invalidate its generic meaning. –  Joonas Pulakka Apr 4 '12 at 14:41

My own tip :

  • big endian = big-end first ! (the first byte (lowest address) is the MSB)
  • little endian = little-end first ! (the first byte (lowest address) is the LSB)
share|improve this answer
2  
Yes, this is the way I think of it: Big Endian "Starts at the BIG end", while Little Endian "Starts at the Little end". It's like a baseball bat, there are two ends of the bat, one is big, the other is little. It's really not that hard of a concept. –  Shane Kilkelly Apr 4 '12 at 12:29

The best way to remember this is that civilized peoples seek out variety and hence eat their eggs differently than they order their numbers. Whereas we write decimal digits starting at the big digits first (big endian), we eat soft boiled eggs from the little end (little endian).

share|improve this answer
    
This answer is mostly non-technical, yet it was completely accurate and made me laugh. Good job. –  Snowman Aug 28 at 23:50

Big-endian numbers start at the "big end". Little-endian numbers start at the "little end".

Both are an allusion to the issue of where to start eating your egg, as per Gulliver's Travels.

In this case, "end" is not the opposite of start, it just means any extreme of a (rope|string|number|sequence), thus them not being called "big finishian" or "little finishian" (which would definitely be the opposite of "start").

share|improve this answer
    
Indeed. And the easiest (and most fun) way of remembering is to go and read Gulliver's Travels. I guarantee you'll never forget which is which again! –  Jules Aug 29 at 13:13

I never could remember which is "big-endian" and which is "little-endian" but knew the endianness of PowerPC and Intel x86 processors. Little has most of the letters in common with Intel, so Intel x86 is little-endian.

Of course that's only useful if you know the byte order of PPC and x86. On the other hand, you should now remember that Intel x86 = little-endian. And remember that x86 and ARM are very, very compatible even with totally different instruction sets.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.