-
Notifications
You must be signed in to change notification settings - Fork 623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inaccurate floating point values since 3.43.0.0 #1002
Comments
Maybe check #927 It's unlikely that it's coming from the driver. Can you try with sqlite cli and compare between versions using the cli? It's most probably coming from sqlite itself. |
You could also add any slf4j implementation and enable trace logs to show what exact sql statements are used. |
The issue is not present in sqlite-tools-win32-x86-3420000.zip and sqlite-tools-win32-x86-3430200.zip. Yes, there were changes in sqlite: https://www.sqlite.org/changes.html. Probably
is the cause. There is the behaviour of both cli-Versions different. Php had similar problems, see https://sqlite.org/forum/forumpost/abc65bec19475130. Can you force sqlite to use the slower algorithm that gives full accuracy? I would prefer it at the cost a few nanosecods. The jni overhead might be bigger. |
Without even knowing where/why it happens, no. |
I've added some tests to run on CI, which fail on Windows only: https://github.com/gotson/sqlite-jdbc/actions/runs/6649079467/job/18067046014 The 3 tests represent different column affinity. You can see in the code of I don't see any good way to bind a For me that's a Sqlite behaviour, nothing we can do in the driver about it. |
How are the windows binaries built? Maybe it's a fault by the compiler. Sadly that is too deep for me. The members of the official forum might help. Here is a test with double values, which surprisingly doesn't fail. So I have the conclusion that the @Test
public void sqliteTestDouble() throws SQLException {
double testValue = 3.14;
try (var conn = DriverManager.getConnection("jdbc:sqlite::memory:")) {
try (var createTblStmt = conn.prepareStatement("create table foo(nr number(15));")) {
createTblStmt.execute();
}
try (var insStmt = conn.prepareStatement("insert into foo(nr) values(?);")) {
insStmt.setDouble(1, testValue);
insStmt.execute();
}
try (var selStmt = conn.prepareStatement("select nr from foo;")) {
if (selStmt.execute()) {
try (var selResult = selStmt.getResultSet()) {
var col1Value = selResult.getDouble(1);
assertEquals(Double.valueOf(testValue), Double.valueOf(col1Value));
}
}
}
}
} |
Note that if you specify the column as The windows binaries are built using dockcross |
This fixes issue xerial#1002.
This solves issue xerial#1002.
🎉 This issue has been resolved in |
Describe the bug
Since 3.43.0.0 some precision of numbers is lost.
To Reproduce
Expected behavior
I expected 3.14 as the returned column value, but it is 3.1399999999999997.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: