[ACCEPTED]-What are the benefits of the different endiannesses?-endianness

Accepted answer
Score: 20

The benefit of little endianness is that 7 a variable can be read as any length using 6 the same address.

For example a 32 bit variable 5 can be read as an 8 bit or 16 bit variable 4 without changing the address. This may have 3 limited benefit these days, but in the days 2 of assembler and limited memory it could 1 be a significant advantage

Score: 4

There is no particular benefit of big or 7 little endian as such, except using native 6 CPU endianness or handling specified file 5 endianness.

The reason why both big and little 4 endian coexist is that different CPU makers 3 used different conventions for representing 2 multibyte data, and no standard emerged 1 at the time.

Score: 1

Using the endianness of the CPU (no matter 21 little or big) gives you the speed benefit 20 on arithmetics: you can add, subtract etc. multibyte 19 integers directly in memory.

Using a predefined, prescribed 18 endianness (no matter little or big) in 17 a file format gives you the benefit of being 16 able to read the file on any system, no 15 matter the endianness of the CPU of the 14 other system. Systems with the right endianness 13 can read the file faster (if the read routine 12 is written and optimized properly), but 11 even systems with the wrong endianness can 10 read it. Usually, the speed difference is 9 negligable (except for very large files 8 with lots of integers), so it is a good 7 idea to first measure the maximum possible 6 speed gain of optimizing the read routine.

Some 5 file formats (for example TIFF) support 4 both endianness. In this case it is a good 3 idea to generate the file with the CPU's 2 endianness, assuming the file would be post-processed 1 on the same machine, or a similar machine.

Score: 1

Certain operations benefit from having parts 13 of a value available before another part. When 12 adding two unsigned or two's-complement 11 numbers which are too large to read all 10 at once, the lower bits of the result can 9 be computed before the upper bits are available, but 8 not vice versa, implying that little-endian 7 order is advantageous there. When accessing 6 a serial flash chip, row decoding can only 5 begin when all of the bits which define 4 the row (typically all but the least-significant 3 8-12 bits, depending on the chip) become 2 available, implying that big-endian order 1 is advantageous there.

More Related questions