Ask a Question related to UNIX Programming, Design and Development.
-
James Leddy #1
endian question
I run an intel i686 processor.
I just wanted to know weather it mattered because of endian how I put data
in a file. If I open a FILE *, say conf, and then I fwrite() to it, will I
mave to make any conversions if I want to fread() from it?
example by c code:
//assume conf is opened for writing and is a new file
int j = 12793;
fwrite(&j, sizeof(int), 1, conf);
//conf is same file, opened for reading and at the start
int j
fread(&j, sizeof(int), 1, conf);
printf("%d", j); //should output 12793
It is my understanding that I should be able to do this without
a problem, but because I have little endian, the actual numbers will be
stored when read in a hex editor as somthing else. (ie 12793 = 0x0000n31F9
will be stored as F9310000) Will this affect the program if I stick to
fread()ing and fwrite()ing?
Thanks
--
-J. Leddy (a.k.a. iustitia)
James Leddy Guest
-
#33227 [Com]: zend_strtod() broken on big-endian arm
ID: 33227 Comment by: terry dot s dot duncan at intel dot com Reported By: jbparsons at ucdavis dot edu Status: ... -
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you
<RonGrossi382872@yahoo.com> wrote in message news:1114393703.900419.199790@f14g2000cwb.googlegroups.com... This is the most important question of... -
.Net webservice and java client little endian/big endian
Hello I have a .Net webservice and java client. In my .Net webservice I want to serialze my object into inline binay data(byte ) inside the soap... -
Marc Rochkind #2
Re: endian question
On Wed, 16 Jul 2003 02:32:49 GMT, James Leddy <iustitia@optonline.net>
wrote:
[snip]> I run an intel i686 processor.
>
> I just wanted to know weather it mattered because of endian how I put
> data
> in a file.
It matters for the same reasons and under the same circumstances as it
matters when you're passing data over a network. Namely:
1. Never for characters, but always for binary data that's more than a
byte.
2. Never when you're internal to a machine, but possibly (which means you
have to account for it) when going between machines.
So... feel free to write binary data however you like if the binary file
stays within a machine, or another machine with the same hardware. But,
take endian into account if you're writing a binary file that's supposed to
be portable.
For this reason, binary interchange formats like, say, TIFF, record the
endian state in the file, and the reading program must take it into
account.
Or... use a 100% character based format, like, say, XML, and the problem
goes away.
--Marc
Marc Rochkind Guest
-
Valentin Nechayev #3
Re: endian question
>>> Marc Rochkind wrote:
MR> It matters for the same reasons and under the same circumstances as it
MR> matters when you're passing data over a network. Namely:
[...]
MR> 2. Never when you're internal to a machine, but possibly (which means you
MR> have to account for it) when going between machines.
There are little exceptions for some unusual;) architectures as ia64 and
power[pc]: endianness can be switched on them, and different OSes can use
different endianness.
MR> 1. Never for characters, but always for binary data that's more than a
MR> byte.
UTF-16 have two different endiannesses.
[...]
MR> Or... use a 100% character based format, like, say, XML, and the problem
MR> goes away.
XML with UTF-8, of course.
-netch-
Valentin Nechayev Guest
-
Erik Max Francis #4
Re: endian question
Valentin Nechayev wrote:
True enough, but any sane UTF-16 stream is going to have the endianness> UTF-16 have two different endiannesses.
marker in it to eliminate any question.
--
Erik Max Francis && [email]max@alcyone.com[/email] && [url]http://www.alcyone.com/max/[/url]
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ You are inspiration to my life / You are the reason why I smile
\__/ India Arie
Erik Max Francis Guest



Reply With Quote

