Joh*_*nny 3 linux sqlite macos
我创建一个表并通过在ARM Linux机器上执行以下操作来填充它
~ # 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
Run Code Online (Sandbox Code Playgroud)
然后我将文件传输到我的Mac并执行以下操作
themac:~ me$ sqlite3 test.db
SQLite version 3.6.12
sqlite> select * from a;
5.30239915051991e-315
Run Code Online (Sandbox Code Playgroud)
Whaaat?我认为数据文件与平台无关.
我对SQLite没有特别的了解,但是这表明有一个问题,即64位IEEE 754格式的两个32位字double被交换,正如您在本例中所看到的(gcc在x86机器上运行) :
$ 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;
}
Run Code Online (Sandbox Code Playgroud)
$ gcc -Wall -o test test.c $ ./test 3ff8000000000000 000000003ff80000 $