Linux和OS X上的Sqlite数据文件不兼容? [英] Sqlite data file on Linux and OS X incompatible?
本文介绍了Linux和OS X上的Sqlite数据文件不兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建一个表并通过在ARM Linux机器上执行以下命令来填充它
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
然后我将文件传输到Mac并执行以下操作
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.
推荐答案
我对SQLite并不了解,但这表明存在一个问题,其中两个64位IEEE 754格式double
的32位字是如本例所示(在x86机器上使用gcc
运行),交换过来了:
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
$
这篇关于Linux和OS X上的Sqlite数据文件不兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文