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?
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?
Endianness is about byte address order. Little endian means the lower significant bytes gets 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 single 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
Little endian is basically reversing the byte order for a multi byte value
1111 1111 1111 0100
is 2 bytes 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
The purpose of big-endian is to print hex on computer screens left-to-right so they are easier to read by low-level or newb programmers; in other words, because the hex gets printed from low memory addresses to high, the hex gets flipped unless you change it in software. The purpose of Little-endian is to not be a wingnut and leave the bytes in sequential order so you don't make extra work for developers and instead make the VERY limited number of people who care flip the bytes around in software!
It is STRONGLY ADVISED to never use big-endian. CPUs today are dual-endian and can handle both big and little endian so unless you're interfacing with legacy hardware almost the entire industry uses little-endian and big-endian has been scheduled to be completely discontinued by developers.
In RAM Printed
+----+ 0x01000000
0x4 | 00 |
| 00 |
| 00 |
0x0 | 01 |
+----+
In RAM Printed
+----+ 0x00000010
0x4 | 01 |
| 00 |
| 00 |
0x0 | 00 |
+----+
In RAM Printed
+----+ 0x00000010
0x4 | 00 |
| 00 |
| 00 |
0x0 | 01 |
+----+
The word Endian is actually an ancient Native Tribe of North America. I can't remember exactly how the story went so please post comments filling in the holes, but the story is that there were two tribes of Endians engaged in a family feud over something silly and eventually the reason why they where feuding was long gone but they where still fighting just because of they were still mad.
The term bananas refer to a famous unscientific study alleged to have been done with monkeys. The "scientists" put a ladder in a room with a bunch of monkeys and put bananas at the top of the ladder. If any of the monkeys tried to climb up the ladder, the mean scientists would spray the all the monkeys with a water. The monkeys learned to beat up any of the monkeys that tried to climb up the ladder to save themselves from getting sprayed. Eventually, the scientists stopped spraying the monkeys, but the monkeys continued to beat up anyone who tried to climb up the ladder. The funny thing about this story is that someone just made it up. This is what it means when something is completely bananas, such as the war on drugs.
Admittidly, if you sprayed monkeys with a firehose there is a good chance the story would be true because the original story didn't inflict enough pain to overcome monkey's love of bananas, but it seams as though real scientists aren't that mean.
To see exactly how banans Big-endian is, Lets look at the origins of big-endian. Back in the dawn of microprocessors when they were still making the masks and machines by hand, the Company Motorola briefly found it was faster at the time to use big endian. At the time Motorola CPUs where the fastest, and they developed a firmly entrenched camp of Big-Endianers. Not long after when they reduced the size of the integrated circuits this performance increase became irrelevant and modern CPUs now are dual-endian and can change endian upon boot. This would mirror identically the Bananas story. Someone misunderstood something, it became popular with people who don't know what they're doing, and now the logic is COMPLETELY BANANAS!!! #DeleteBigEndian