I was wondering about the different behavior of inserting a Double as a
String vs as a value with a prepare statement in C.

Consider an example when the value: 62.027393 is inserted as a String and
as value with a prepared statement, for instance:

"CREATE TABLE test (foo REAL)"

"INSERT INTO test (foo) VALUES (?)"

"INSERT INTO test (foo) VALUES (62.027393)"

"SELECT * FROM test"

If the content of the table test, is printed, then the output of the values
is equal i.e. 62.027393. However, if the stored value is compared with for
instance a cross join:

select * from test as a cross join test as b where a.foo = b.foo;

Then two rows are returned which indicates that the values are not equal
(four rows should be returned if they are equal).

If the value 62.027393000000004 is inserted as value with the prepare
statement instead of 62.027393 in the example, then the insert as String
and the insert as prepare statement is equal.

The double seems to be changed from 62.027393 to 62.027393000000004 when
inserted as a String. This happens with some other values too (but not all).

The values should be equal and i wonder if this is a bug or intendent

Best regards

sqlite-users mailing list

Reply via email to