[ee122] More byte ordering..

vern at cs.berkeley.edu vern at cs.berkeley.edu
Mon Nov 26 18:18:50 PST 2007


> Suppose we want to convert everything

Just what constitutes "everything" goes to the heart of the question.
Byte ordering is about how are multi-byte data types represented in memory.
To define a byte order therefore requires specifying how many bytes are
in the data type.

For strings, there is only one natural order, namely that the starting
character is at the lowest position in memory, and the remainder follow
in order towards higher positions in memory.  (If instead strings grew
downward towards lower memory, then array arithmetic wouldn't work on them
as a way to extract a particular character.)

> previous email you sent suggested to convert "everything" to network
> byte order to be safe...

He means all data types with fixed, multi-byte representations, as for
these there's an ambiguity whether the topmost byte comes first or last.
(The issue about array arithmetic doesn't arise because these data types
don't directly support extraction of their individual bytes.  The bytes
are always supposed to be treated as a unit.)

		Vern


More information about the ee122 mailing list