Kelly Jones
2009-05-25 06:28:59 UTC
I tried inserting 2^63-1 and the two integers after it into an SQLite3
db, but this happened:
SQLite version 3.6.11
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE test (test INT);
sqlite> INSERT INTO test VALUES (9223372036854775807);
sqlite> INSERT INTO test VALUES (9223372036854775808);
sqlite> INSERT INTO test VALUES (9223372036854775809);
sqlite> .mode line
sqlite> SELECT * FROM test;
test = 9223372036854775807
test = 9.22337203685478e+18
test = 9.22337203685478e+18
sqlite> SELECT * FROM test WHERE test = '9223372036854775808';
test = 9.22337203685478e+18
test = 9.22337203685478e+18
Why the sudden switch to scientific notation and loss of precision?
Are 64-bit integers signed (ie -2^63 to 2^63-1)? Can I "unsign" them?
Since sqlite3 uses 64-bit ints for rowid, I figured they'd be unsigned.
Workarounds?
db, but this happened:
SQLite version 3.6.11
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE test (test INT);
sqlite> INSERT INTO test VALUES (9223372036854775807);
sqlite> INSERT INTO test VALUES (9223372036854775808);
sqlite> INSERT INTO test VALUES (9223372036854775809);
sqlite> .mode line
sqlite> SELECT * FROM test;
test = 9223372036854775807
test = 9.22337203685478e+18
test = 9.22337203685478e+18
sqlite> SELECT * FROM test WHERE test = '9223372036854775808';
test = 9.22337203685478e+18
test = 9.22337203685478e+18
Why the sudden switch to scientific notation and loss of precision?
Are 64-bit integers signed (ie -2^63 to 2^63-1)? Can I "unsign" them?
Since sqlite3 uses 64-bit ints for rowid, I figured they'd be unsigned.
Workarounds?
--
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.