yep i forgot to mention the paltforms for C

-Ashish

----- Original Message -----
From: "Matthias Pfisterer" <[EMAIL PROTECTED]>
To: "Ashish" <[EMAIL PROTECTED]>
Cc: "Joaquin Rapela" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, March 21, 2001 5:13 PM
Subject: Re: readInt() & byte order


> Ashish wrote:
> >
> > Answer is simple
> >
> > Java program expects file bytes in big-endian format, while C uses
little
> > endian
>
> Sorry, wrong. C uses the native byte order of the system. I.e. it
> depends on the processor.
> x86 (Intel, AMD) => little endian
> PowerPC, Alpha, Sparc => big endian
>
> Matthias
>
> > 2175 = > 00001000   01111111
> >
> > so java will interpret after assuming it's big endian will be 01111111
> > 00001000 => 32520
> >
> > -Ashish
> >
> > ----- Original Message -----
> > From: "Joaquin Rapela" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, March 21, 2001 9:56 AM
> > Subject: readInt() & byte order
> >
> > > Hello,
> > >
> > > I have a binary file containing short integers. I wrote a C program to
> > read
> > > the file and it works as expected. I wrote a java program to read the
file
> > > using a DataInputStream and its readInt() method and it is reading the
> > short
> > > integers in inverted order Instead of a 2175 (100001111111) I get a
32520
> > > (111111100001000). To read the integers I read the following code:
> > >
> > > File inputFile = new File(filename);
> > > in = new DataInputStream(new FileInputStream(filename));
> > > short current = -1;
> > > current = in.readShort();
> > >
> > > Is there something wrong with this? Shall I use another method?
> > >
> > > Thanks in advance, Joaquin


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to