Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Little Endian vs Big Endian?

Tags:

endianness

I'm having troubles wrapping my head on the two. I understand how to represent something in big endian.

For example -12 is 1111 1111 1111 0100

But why is the little endian representation 1111 0100 1111 1111 instead of 0100 1111 1111 1111?

like image 700
Clinton Jooooones Avatar asked Feb 26 '14 02:02

Clinton Jooooones


People also ask

Why is Little Endian better?

The benefit of little endianness is that a variable can be read as any length using the same address. One benefit of big-endian is that you can read 16-bit and 32-bit values as most humans do; from left to right.

What is little endian and big-endian with example?

Specifically, little-endian is when the least significant bytes are stored before the more significant bytes, and big-endian is when the most significant bytes are stored before the less significant bytes. When we write a number (in hex), i.e. 0x12345678 , we write it with the most significant byte first (the 12 part).

Is big or little endian more common?

By far the most common ordering of multiple bytes in one number is the little-endian, which is used on all Intel processors.

How is data stored in little endian?

Little Endian Byte Order: The least significant byte (the "little end") of the data is placed at the byte with the lowest address. The rest of the data is placed in order in the next three bytes in memory.


2 Answers

Endianness is about byte address order. Little endian means the lower significant bytes get the lower addresses. Big endian means the other way around. So it's about the bytes (8-bit chunks) not nibbles (4-bit chunks). Most computers we use (there are a few exceptions) address bytes at the individual address level.

Taking the -12 example:

Little endian, in memory, would be:

000000: F4
000001: FF

Big endian, in memory, would be:

000000: FF
000001: F4
like image 99
lurker Avatar answered Oct 19 '22 14:10

lurker


Little endian is basically reversing the byte order for a multi byte value.

1111 1111 1111 0100 is a 2 byte value where 1111 1111 is the first byte and 1111 0100 is the second byte. In little endian, the second byte (or least significant byte) is read in first so the final representation is 1111 0100 1111 1111.

like image 28
bakalolo Avatar answered Oct 19 '22 15:10

bakalolo