Hi people,
I'm having some problems with arm endianess of floating types.
For example, the "double" value 10.0:
my PC writes it to a file:
0x00.00.00.00.00.00.24.40
while the TS-arm writes:
0x00.00.24.40.00.00.00.00
So, when arm reads a binary file written by a PC it interprets a wrong value,
and vice-versa. This causes a lot of problems when using third part libraries
and standards.
If anyone wants to check, I attached a program to illustrate it. Running it on
PC and on ARM will show the numbers above.
Regards
Adriano
#include <iostream>
#include <fstream>
using namespace std;
int main() {
double d = 10.0;
ofstream of("teste.bin");
of.write((const char *)&d, sizeof(double));
of.close();
ifstream ifs("teste.bin");
for (unsigned int j = 0; j < sizeof(double); j++)
{
char c;
ifs.read(&c, 1);
cout << "in the file, i["<< j << "] = "<< std::hex << (int)c <<
endl;
}
ifs.close();
return EXIT_SUCCESS;
}
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|