Wednesday, November 26, 2008

Big endian VS little endian, which one is better ?

http://www.cs.umass.edu/~Verts/cs32/endian.html

Which is Better?

You may see a lot of discussion about the relative merits of the two
formats, mostly religious arguments based on the relative merits of
the PC versus the Mac. Both formats have their advantages and
disadvantages.

In "Little Endian" form, assembly language instructions for picking up
a 1, 2, 4, or longer byte number proceed in exactly the same way for
all formats: first pick up the lowest order byte at offset 0. Also,
because of the 1:1 relationship between address offset and byte number
(offset 0 is byte 0), multiple precision math routines are
correspondingly easy to write.

In "Big Endian" form, by having the high-order byte come first, you
can always test whether the number is positive or negative by looking
at the byte at offset zero. You don't have to know how long the number
is, nor do you have to skip over any bytes to find the byte containing
the sign information. The numbers are also stored in the order in
which they are printed out, so binary to decimal routines are
particularly efficient.

No comments: