S
Sheldon
Hi,
I am trying to make sense of this endian problem and so far, it is
still Greek to me.
I am have some files that have stored lat and lon data in binary
format. The data was originally floats (32) and written in with the
most significant byte in the lowest address (big endian). I have an
Intel processor and working in Mandrake. In Python, I have solved this
with a built in function, but in C, I am at a loss. What I have grasp
so far is that the data ought to read in an unsigned char array and
then I have to look at the data bit by bit and then swap them. It is
this part that looses me.
I have seen this example for an int 32:
unsigned char j[4];
uint32_t o;
read(descriptor, j, 4); /* error checking ommitted for simplicity */
o = j[0]; o<<=8;
o | = j[1]; o<<=8;
o | = j[2]; o<<=8;
o | =j[3];
Could someone please explain what this person did, or, explain how to
do this byte swap?
Sincerely,
Sheldon
I am trying to make sense of this endian problem and so far, it is
still Greek to me.
I am have some files that have stored lat and lon data in binary
format. The data was originally floats (32) and written in with the
most significant byte in the lowest address (big endian). I have an
Intel processor and working in Mandrake. In Python, I have solved this
with a built in function, but in C, I am at a loss. What I have grasp
so far is that the data ought to read in an unsigned char array and
then I have to look at the data bit by bit and then swap them. It is
this part that looses me.
I have seen this example for an int 32:
unsigned char j[4];
uint32_t o;
read(descriptor, j, 4); /* error checking ommitted for simplicity */
o = j[0]; o<<=8;
o | = j[1]; o<<=8;
o | = j[2]; o<<=8;
o | =j[3];
Could someone please explain what this person did, or, explain how to
do this byte swap?
Sincerely,
Sheldon