Xojo 2014r2.1
I’m getting wrong double values from SQLite REAL datatypes columns.
I have a complex database storing a lot of very small weights (up to 8 digit right of decimal point) defined as REAL in the SQLite DB.
When I read the DB the DatabaseField.DoubleValue are not always correct.
I created a test DB with a single file containing a single column:
CREATE TABLE "testDbl" ( "ID" INTEGER NOT NULL PRIMARY KEY , "RealValue" REAL);
I’ve inserted 10 rows as:
INSERT INTO "testDbl" VALUES (1, 0.84);
INSERT INTO "testDbl" VALUES (2, 10.1129);
INSERT INTO "testDbl" VALUES (3, -1.84);
INSERT INTO "testDbl" VALUES (4, -0.53);
INSERT INTO "testDbl" VALUES (5, 18.0);
INSERT INTO "testDbl" VALUES (6, 10.0);
INSERT INTO "testDbl" VALUES (7, 154.0);
INSERT INTO "testDbl" VALUES (8, 33580.0);
INSERT INTO "testDbl" VALUES (9, 1107.7);
INSERT INTO "testDbl" VALUES (10, 0.4874);
If I read this table and move the “Value” column into a double variable I get wrong values for some (in bold), correct ones for others:
ID / RealValue / rs.field(“RealValue”).DoubleValue
1/ 0.84 / 0.84
2/ 10.1129 / 10.1128999999999998
3/ -1.84 / -1.8400000000000001
4/ -0.53 / -0.53
5/ 18.0 / 18.00
6/ 10.0 / 10.0
7/ 154.0 / 154.0
8/ 33580.0 / 33580.0
9/ 1107.7 / 1107.7000000000000455
10/ 0.4874 / 0.4874
Double values are checked using debug and using format(rs.Field(“RealValue”).DoubleValue, “#####0.00000000000000000”)
If I export the values to CSV or XLS I’m getting the correct values.
I’m experiencing the same problem using SQLitedatabase (Xojo) and cubeSQL database.
I can provide the testDB and a testApp
Any hint or workaround welcome !
Thanks and regards,
Olivier