Hello,

The processor where I am running my instance of SQLite has a problem in
that it serializes double-precision floating point values incorrectly. If
the 8-byte double should be stored as 0x123456789ABCDEF0, it is instead
stored as 0x9ABCDEF012345678. Four-byte floating point values are stored
correctly.

This problem does not cause any grief when the data is created and consumed
on the system where SQLite is running because the processor both reads and
writes doubles the way I described above (switches the first four bytes
with the second four bytes). However, this does become a problem when the
data saved on this system is read by another system.

Is there a way that I can force SQLite to store a float in the database
instead of a double? We have addressed this problem elsewhere by using a
float instead of a double wherever serialization is involved (since we do
not need the extra precision).


Other solutions I have considered, but have decided are undesirable:

1) Address this in the compiler (gcc). This is probably the "right"
solution, but this is an older system, and setting up the updated
cross-compiler is intimidating. I have never modified gcc before, so I am
worried that I would miss something, and it would manifest itself in a
nefarious bug later on.

2) Store the values as text in the database. This would fix the
serialization problem, but wouldn't it prevent me from running queries that
treat these data as numbers?

3) Account for this problem on other systems by correcting the order of the
bytes there in an analysis tool that I provide. I really don't want to use
this solution because part of the lure of storing data in SQLite is that we
can take advantage of other readers that already exist.

I appreciate any advice/help that you can offer.

Thank you,
Mike Foss
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to