19

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?

dodgy_coder
  • 1,098
  • 7
  • 22
Emiliano
  • 1,236
  • 1
  • 10
  • 17
  • 14
    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 04 '12 at 11:44
  • 3
    Funny coincidence - I only stumbled on this link today, and it's surprisingly relevant http://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html – Nevermind Apr 04 '12 at 14:56
  • 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](http://en.wikipedia.org/wiki/Endianness). – mouviciel Apr 04 '12 at 12:49
  • @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](http://www.fun-with-words.com/ambiguous_garden_path.html), 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 01:11

9 Answers9

42

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)
KB99
  • 421
  • 1
  • 3
  • 2
  • 5
    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 04 '12 at 12:29
  • The confusion may be cultural. In English, end means the part where something stops, whichever way you look at it. In (most?) other languages end is first and formost associated with the rear part, as opposed to start or beginning. – Martin Maat Jul 04 '22 at 07:10
17

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).

Joonas Pulakka
  • 23,534
  • 9
  • 64
  • 93
  • 7
    ahh, but the little-endian lilliputians started (cracked) their eggs at the little end so it is the right way round – jk. Apr 04 '12 at 11:57
  • 4
    -1: Endian-ness refers to bytes within a word, not bits within a byte. – kdgregory Apr 04 '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 04 '12 at 12:54
  • @Kdgregory: [According to Wikipedia](http://en.wikipedia.org/wiki/Endianness), *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](http://en.wikipedia.org/wiki/Bit_numbering). 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 04 '12 at 12:55
  • @Joonas - if you know of a bit-addressible general purpose processor, then feel free to add a link to your answer and I'll remove the downvote. Otherwise, your response is incorrect with respect to the question asked. – kdgregory Apr 04 '12 at 13:03
  • 4
    @kdgregory: Since when is existence of hardware required to justify CS theoretical notions? But very well: [8051](http://en.wikipedia.org/wiki/Intel_MCS-51) has bit-addressable registers. Ada language allows specifying the appropriate bit order for data type representation ([pdf](http://researchweb.watson.ibm.com/people/n/ncohen/EndianIndepRecRepClauses.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 04 '12 at 14:41
  • @JoonasPulakka Big-endian and Little-endian really started out as machine-oriented specifics, rather than as "Pure Theoretical CS notions", so I guess I could argue this both ways. Unless we're looking at bit-level transmissions, I guess the endian-ness of octets very rarely matter on most modern machines. – Vatine Aug 29 '15 at 13:33
8

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").

Vatine
  • 4,251
  • 21
  • 20
  • 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
  • You should put "start eating" in bold (also 72pt, ), that's really the whole reason for all the confusion here. – T Nierath Oct 22 '18 at 09:00
6

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).

Andrey Fedorov
  • 177
  • 1
  • 1
  • 1
    This answer is mostly non-technical, yet it was completely accurate and made me laugh. Good job. –  Aug 28 '15 at 23:50
3

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).

dreamlax
  • 161
  • 3
  • Feel free to pronounce startian as **/'stɑːr.ʃən/** or **/'stɑːr.ti.ən/** (omit the /r/ for non-rhotic accents) – dreamlax Apr 28 '16 at 03:35
  • This is pretty clever, and easy to remember. – Coldblackice Nov 10 '19 at 05:13
  • Yes, I use the adjective "frontian" but it is the same thing. – Gringo Suave May 24 '22 at 18:46
  • This doesn't make sense to me. The big end and little end is where you start. In the original story (Gulliver's Travels) about which end of the egg to break they don't call themselves "big-breakian" and "little-breakian". – Florian F May 26 '22 at 21:45
1

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.

gnasher729
  • 42,090
  • 4
  • 59
  • 119
0

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

0

From Wikipedia:

A big-endian system stores the most significant byte of a word at the smallest memory address and the least significant byte at the largest.

A little-endian system, in contrast, stores the least-significant byte at the smallest address.

It's really a matter of byte alignment in memory. Thus, just remember that:

LIttle-endian bytes are aLIgned.

smallest memory address = smallest (least significant) byte;

and

largest memory address = largest (most significant) byte.

It then follows that big-endian bytes are not aligned.

Piovezan
  • 449
  • 4
  • 13
-1

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