Byte order (retitled)

Henry Spencer henry at utzoo.UUCP
Fri Apr 11 06:45:45 AEST 1986


> 	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.

If your machine has unsigned characters and two's-complement integers with
the sign bit in the high bit -- e.g. 360/370 -- then neither byte order
will make the two comparisons come out the same.  So quite apart from all
the other flaws in this argument, it just doesn't work.

Before you start defending signed characters, remember that they were
another arbitrary invention of the pdp11.  And a mistake, too.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry



More information about the Comp.lang.c mailing list