[CLUE-Tech] Byte Order

Match Grun match at dimensional.com
Wed Dec 20 13:14:05 MST 2000


Gary,

I don't know if this helps:

If you create a regular file, then the contents should render correctly.
If this was not the case, the every pair of characters in a regular text
file would be transposed!!! Obviously this does not happen.

However, if you are doing network programming, you should always
work in Network Byte Ordering. I believe network byte ordering is
big endian. I am not sure what type of application you are working
with. However, both Linux socket library and Windoze winsock
library provide functions to ensure this translation.

Match

gary.l.shapiro at lmco.com wrote:

> Thanks, but this doesn't help. The machine is a little endian architecture. What I want to know is, how come it writes in big endian mode?
>
> Gary
>
> -----Original Message-----
> From: Dave Hahn [mailto:dhahn at techangle.com]
> Sent: Wednesday, December 20, 2000 11:08 AM
> To: clue-tech at clue.denver.co.us
> Subject: Re: [CLUE-Tech] Byte Order
>
> Gary:
>
> Found this note on a google search.  Not sure if it helps or not, but it is,
> at least, a description.  Although Linux will operate on little-endian or
> big-endian machines, data storage seems to be the kicker in moving
> information back and forth.
> =====
>
> Linux has been written on a little endian architecture: intel. In
> little-endian mode linux is well tested, the kernel works perfectly. If you
> chose big-endian mode, linux is still operational, but some parts of the
> kernel will be broken. Drivers, filesystems etc...  must be written in a
> big-endian compatible way, all 16bits, 32bits access to hardware or to
> external data structures must be converted using some macros defined in the
> linux kernel.
>
> -Dave Hahn
> -TechAngle Inc.
> -dhahn at techangle.com
> ----- Original Message -----
> From: <gary.l.shapiro at lmco.com>
> To: <clue-tech at ta8.techangle.com>
> Sent: Wednesday, December 20, 2000 9:52 AM
> Subject: [CLUE-Tech] Byte Order
>
> > I just started using a Linux computer for the first time, and I've already
> noticed a peculiar phenomenon. We have some code which was designed to be
> portable: it works on both PC (Windows) and Unix platforms. To do this, the
> code performs a "check" on the byte order, which consists of placing a short
> constant (1) in memory, then examining the first byte. If the byte is 1, the
> machine is LittleEndian, if 0, the machine is BigEndian. Of course, the
> Linux machine, being an Intel, is LittleEndian. When the data is written to
> a binary file using fwrite, however, it writes it in BigEndian order. Is
> this normal for Linux? Of course, the data is "marked" as LittleEndian, even
> though it is written as BigEndian, which creates problems when I read in the
> data for another program. The obvious solution is to override the byte check
> when using Linux. If this is standard Linux behavior, what indicator can I
> use to do this and still keep the current behavior on Windows and Unix
> platforms?
> >
> > Gary Shapiro
> > Software Engineer
> > Advanced Processing Group
> > Lockheed Martin Space Systems / Astronautics Operations
> > Denver, CO
> > _______________________________________________
> > CLUE-Tech mailing list
> > CLUE-Tech at clue.denver.co.us
> > http://clue.denver.co.us/mailman/listinfo/clue-tech
> >
>
> _______________________________________________
> CLUE-Tech mailing list
> CLUE-Tech at clue.denver.co.us
> http://clue.denver.co.us/mailman/listinfo/clue-tech
> _______________________________________________
> CLUE-Tech mailing list
> CLUE-Tech at clue.denver.co.us
> http://clue.denver.co.us/mailman/listinfo/clue-tech




More information about the clue-tech mailing list