Byte order (retitled)

Doug Gwyn gwyn at brl-smoke.ARPA
Wed Apr 9 05:42:23 AEST 1986


In article <7046 at cca.UUCP> g-rh at cca.UUCP (Richard Harter) writes:
>	Well, no, little-endian came about because the engineers at DEC
>who designed the PDP-11 made an arbitrary decision that was not well
>thought out.  I will not essay to defend the sanity of DEC engineers,
>and cannot recommend that any one else do so (:-)).  It was a bad
>decision.

One advantage of DEC's decision was that passing numeric quantities
by reference to procedures was simplified; the procedure could use
the lower bits of the parameter without worrying about the size of
the parameter.  This made code generation (e.g. Fortran) easier and
was a real programmer convenience (I certainly exploited it myself).

When the FP11 was designed, DEC screwed up and got the 4-byte (long)
integer format wrong (since fixed in the VAX-11, which was otherwise
most careful to use PDP-11 compatible data formats).  Some Fortrans
kept the bytes in little-endian order anyway, so as not to lose
the above-mentioned advantage, and reshuffled them during FP11
operations.

Many implementors of C on big-endian machines have had to cope with
the pointer conversion problem, which is simpler on little-endians.

>	Consider the following problem.  You have an array of 4 byte
>integers.  If you sort the array numerically you get one result.  If
>you regard the bytes as characters and sort them lexicographically on
>a little endian machine you get a different result.  The reason is that
>the most signifigant byte occupies the eight least signifigant bits.
>Consistency of signifigance requires that the direction of signifigance
>be the same for both bytes and bits.

This is not a practical example.  If it were, you would have to
make the same argument for floating-point numbers, records from
a file, and so on.

>In short, little-endian was a mistake, is a mistake, and will continue
>to be a mistake.

About the only thing that is clear, apart from the better fit of
big-endian to block-oriented operations and of little-endian to
stream-oriented ones, is that this is a "religious issue".



More information about the Comp.lang.c mailing list