Re: Cohen's paper on byte order

From: Paul Schlyter (pausch_at_saaf.se)
Date: 04/27/03


Date: Sun, 27 Apr 2003 20:25:23 +0000 (UTC)

In article <3EAB9FF3.E3CAD661@t-online.de>,
Mok-Kong Shen <mok-kong.shen@t-online.de> wrote:
 
> "Douglas A. Gwyn" wrote:
>>
>> Mok-Kong Shen wrote:
>>> http://whatis.techtarget.com/definition/0,,sid9_gci211659,00.html
>>> It is possible to be big-endian or little-endian about
>>> the bit order, but CPUs and programs are almost always
>>> designed for a big-endian bit order.
>>
>> It has already been pointed out that that is wrong.
>
> What is then the 'right' situation? The opposite?
 
One reason to favor little-endian order, from a CPU point of view, is
that that's the way you do the computation. As an illustration, try
to add two multi-digit numbers with pencil and paper. You start with
the least significant digit, and then go up towards the more
significant digits, propagating the carries along the way. Now try
to add starting with the most significant digit instead: it'll work
fine until you encounter a carry - then you have to backtrack to add
it to the more significant digit you've already processed. This is
somewhat more complex, and in some CPU's it could mean somewhat
longer processing time.
 
In software packages doing "biginteger" (i.e. multiword) arithmetic,
the most significant word usually appears first, i.e. in big endian
order, also on architectures which are natively little-endian. This
means that the software will start by having to locate the last word,
and then start to work from there. If the words had been stored in
little-endian order, this first step could have been skipped, with a
somewhat faster performance as a result.
 
The only reason to favor big-endian order is cultural ("it's easier
for a human to read"): we read text from left to right, and we put
the most significant digit to the left. If you instead had e.g.
Arabic as your native language, your natural order would be little
endian instead: in Arabic you read from right to left, but you put
the most significant digit in a number to the left anyway. Of course
the "little end" would then be to the right -- but you'd prefer to
start reading from the right.
 

-- 
----------------------------------------------------------------
Paul Schlyter,  Swedish Amateur Astronomer's Society (SAAF)
Grev Turegatan 40,  S-114 38 Stockholm,  SWEDEN
e-mail:  pausch at saaf dot se
WWW:     http://hem.passagen.se/pausch/index.html
         http://home.tiscali.se/~pausch/


Relevant Pages

  • Re: Cohens paper on byte order
    ... > One reason to favor little-endian order, from a CPU point of view, is ... > to add starting with the most significant digit instead: ... > the most significant word usually appears first, i.e. in big endian ... On both big- and little-endian machines, ...
    (sci.crypt)
  • Re: Cohens paper on byte order
    ... > sequence or a hex sequence in the 'little-endian' way?) ... with the least significant digit. ... sequence of digits in the little-endian way. ... pausch at saaf dot se ...
    (sci.crypt)