dlang-community / d2sqlite3

A small wrapper around SQLite for the D programming language
Boost Software License 1.0
75 stars 26 forks source link

Querying double numbers only return 4 significant digits... #63

Closed Robert-M-Muench closed 4 years ago

Robert-M-Muench commented 4 years ago

I'm querying a value which is stored like this in SQLite 82.5850709125308 but get back `82.5851``

How can I get back the full precision?

biozic commented 4 years ago

How did you check the value you got back from the database? 82.5851 is what writeln would print but not what the actual value is.

See:

unittest {
    auto db = Database(":memory:");
    db.run("CREATE TABLE test (val FLOAT)");
    db.run("INSERT INTO test (val) VALUES (82.5850709125308)");
    auto value = db.execute("SELECT val FROM test").oneValue!double;
    assert(value == 82.5850709125308);
}
Robert-M-Muench commented 4 years ago

Ups, sorry. Didn't know that writeln doesn't spit out maximum precision by default. Things work.