[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Big-endian/little-endian (WAS: Re: can I burn the output of mpg123 -s?)



Hi!

Some of my programs have to work on big-endian and little-endian systems,
knowing what kind of system they are runing on (they are exchanging data
in binary format). To recognize the kind of the system I use the following
routine:

int TestByteOrder()
{
   union
   {
      unsigned char c[2];
      unsigned short int u;
   } tst;
   tst.c[0]=0;
   tst.c[1]=0;
   tst.u=258;
   if ((tst.c[0]==1) && (tst.c[1]==2)) return 1; /* big-endian */
   if ((tst.c[0]==2) && (tst.c[1]==1)) return 0; /* little-endian */
   return -1; /* This should not happen! Unknown integer representation */
}
					Greetings
					Wojtek Zabolotny
					wzab@ipebio15.ipe.pw.edu.pl


On Tue, 18 Aug 1998, Stephen J. Carpenter wrote:

> On Tue, Aug 18, 1998 at 02:46:11AM +0100, robbie@scot-mur.demon.co.uk wrote:
> > On Mon, Aug 17, 1998 at 12:10:15PM -0500, the lone gunman wrote:
> > > On Mon, Aug 17, 1998 at 05:32:06PM +0100, robbie@scot-mur.demon.co.uk wrote:
> > > 
> > > Does that mean that "intel byte order" is the same as "host byte
> > > order"?
> > Yes.
> 
> well its not on my Sun IPC :)
> 
> > >   The man page for mpg123 says its output with the -s switch is
> > > "host byte order," but the cdrecord manpage makes no mention of host
> > > byte order, only intel byte order, little endian and big endian, and I
> > > have no clue what else.
> > > 
> > > Can anyone offer an equivalence table for these types?
> > ok
> > 
> > Little endian = intel byte order = host byte order (if its an intel)
> > big endian = network byte order = host byte order (on 64 bit boxes)?
> 
> I dunno if ALL 64 bit boxen are big endian.
> I know SUN systems are big-endian...I don't know about PPCs, or ALphas tho
> 
> -Steve
> -- 
> /* -- Stephen Carpenter <sjc@delphi.com> --- <sjc@debian.org>------------ */
> E-mail "Bumper Stickers":
> "A FREE America or a Drug-Free America: You can't have both!"
> "honk if you Love Linux"
> 


Reply to: