2
About numerical accuracy in Sqlite v3.20.0. See the sequence of commands below and the result of .dump. The value associated with the INSERT declaration is not the same value obtained. I enter the value 123456.789 and get 123456.7890000000043. How can this occur?
SQLite version 3.20.0 2017-08-01 13:24:15
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> CREATE TABLE Teste (Campo Number(9,3));
sqlite> INSERT INTO Teste Values (123456.789);
sqlite> SELECT * From Teste;
123456.789
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE Teste (Campo Number(9,3));
INSERT INTO Teste VALUES(123456.7890000000043);
COMMIT;
sqlite>
More Has How To Solve It?
– Edu Mendonça
In these cases the best is to treat without decimals, that is always as whole, and at the time of displaying the data, makes the division, including the decimals you want. Ex: 123,45 = 12345/100
– Alexandre Cavaloti