sqlite3_bind_double and sqlite3_column_double will round trip IEEE floating point values EXCEPT for NaN. NaN will be stored as a NULL.
-- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-----Original Message----- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Eric Reischer >Sent: Wednesday, 31 July, 2019 15:15 >To: sqlite-users@mailinglists.sqlite.org >Subject: [sqlite] Floating point literals > >Is there a way to pass binary representations of floating point >numbers to >a SQL query? If sqlite's internal representation of floating point >numbers is 8-byte IEEE doubles, it would be convenient to be able to >pass >the literal value of a float or double to the underlying SQL parser >without suffering the quantization that occurs with printf()'ing >floating >point values. > >One way I've accomplished this in the past with other interfaces is >to >interpret a hex value as a binary literal that can be interpreted as >a raw >4-byte or 8-byte IEEE floating-point value (either via a union or >other >compiler trick). I understand you can *retrieve* a non-quantized >value >using sqlite3_column_double(), but I don't see a way to set one >without >having to printf() the floating point value. > >Can this be done using sqlite3_bind_* interfaces, or do they quantize >as >well? The documentation isn't clear on this. The goal is to copy >the >straight 8-byte (or precision-extended 4-byte) IEEE value into the >column >into the database (where the column is defined as a FLOAT) without >having >to build a SQL statement that has an obscene number of digits in each >floating point field. > >Thanks in advance. >_______________________________________________ >sqlite-users mailing list >sqlite-users@mailinglists.sqlite.org >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users