Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
9  
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
3  
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
    
@Nevermind I stopped reading that article after the second paragraph. "Of interest only to compiler writers and people who have to deal with memory mapped to registers"? Besides the fact that that's an awful garden path sentence, it implies that code that deals with registers is an edge case. Try using a computer sometime without device drivers. – dodgethesteamroller Sep 16 '15 at 1:11
up vote 11 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
1  
@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
3  
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
1  
This answer is mostly non-technical, yet it was completely accurate and made me laugh. Good job. – Snowman Aug 28 '15 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 '15 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

I'd put it this way: Big is beautiful!

Big == beautiful == right.
The right endianess is the one that you can read in a hexdump, which is the one that puts the most significant byte first, as any sane human does.

Little == ugly == wrong.
The hexdumps produced by this endianess are just so plain wrong that you run away screaming "Brains!". Maybe this is some kind of alien abomination, we can only speculate to the origin of this atrocity. Nevertheless, it exists, and we are stuck with it.

Pitty, it's not always the best variant that makes the race...

share|improve this answer

The easiest way for me to remember is to change the word “endian” into “startian”. Big startian integers start with the big end (e.g. most significant bytes come first), and little startian integers start with the little end (e.g. least significant bytes come first).

share|improve this answer
    
Feel free to pronounce startian as /'stɑːr.ʃən/ or /'stɑːr.ti.ən/ (omit the /r/ for non-rhotic accents) – dreamlax Apr 28 at 3:35

In big endian : (Ascending order)

Low to high i.e.

0 | 1 | 2 | 3 ^ ^ Start End

In little-Endian : (Descending order)

High to low

i.e.

3| 2 | 1 | 0 ^ ^ Start End

share|improve this answer
1  
The question asked for a practical trick to remember which one. – gnasher729 Apr 2 at 7:45

protected by gnat Apr 2 at 0:19

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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