SQLite Forum

.dumping floats: regression?

.dumping floats: regression?

(1) By anonymous on 2022-02-15 08:22:45 [source]


I .dump (as part of a regression test) a database with floats that can be written exactly in decimals.

Old sqlite 3.7.3 prints them exactly:

INSERT INTO signals VALUES(1,1,1,'de',32,32,120002,'',32,'N','s',5368710.0,0.0,1073741824.0,'Einschaltdauer ASG',NULL,NULL,NULL,NULL,NULL,NULL,1.0,0.0,1.0,'s',3,NULL,NULL,NULL,'');

Recent 3.37.2 prints them with lots more digits but not correctly:

INSERT INTO signals VALUES(1,1,1,'de',32,32,120002,'',32,'N','s',5368709.9999999999999,0.0,1073741823.9999999999,'Einschaltdauer ASG',NULL,NULL,NULL,NULL,NULL,NULL,1.0,0.0,1.0,'s',3,NULL,NULL,NULL,'');

If I am not mistaken, 1073741824 can be stored in a IEEE float (or double) exactly. Would it be possible to .dump it as 1073741824.0? Can there anything be done about this difference?

Regards Hartmut

(2) By Larry Brasfield (larrybr) on 2022-02-15 14:24:18 in reply to 1 [link] [source]

The behavior you call a "regression" has been changed so that floats with an exact, 64-bit integer representation will print without a trailing fractional part that is inexact (as floats generally are and understood to be.)

This change should appear in the upcoming 3.38 release or intervening snapshots.

(3) By anonymous on 2022-02-15 17:01:55 in reply to 2 [link] [source]

Thank you very much for this change!