I create a table and fill it by executing the following on an ARM Linux machine
~ # sqlite3 /mnt/mmc/test.db
SQLite version 3.6.12
sqlite> create table a (d);
sqlite> insert into a values (1.5);
sqlite> select * from a;
1.5
I then transfer the file to my Mac and execute the following
themac:~ me$ sqlite3 test.db
SQLite version 3.6.12
sqlite> select * from a;
5.30239915051991e-315
Whaaat? I thought the data file was platform independent.
I have no particular knowledge of SQLite, but this is indicative of a problem where two 32-bit words of a 64-bit IEEE 754 format double
are swapped over, as you can see in this example (which was run using gcc
on an x86 machine):
$ cat test.c
#include <stdio.h>
int main(void)
{
union {
double d;
unsigned long long ull;
} u;
u.d = 1.5;
printf("%016llx\n", u.ull);
u.d = 5.30239915051991e-315;
printf("%016llx\n", u.ull);
return 0;
}
$ gcc -Wall -o test test.c $ ./test 3ff8000000000000 000000003ff80000 $
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With