On Wednesday, 12 June, 2019 07:35, Richard Hipp <d...@sqlite.org> wrote:
>IEEE754 floating point numbers have separate representations for +0.0 >and -0.0. As currently implemented, SQLite always display both >quantities as just "0.0". >Question: Should SQLite be enhanced to show -0.0 as "-0.0"? Or, >would that create unnecessary confusion? By "on output" one assumes that you mean "when converted to text representation" and not that you are messing with the actual stored floating point number that is "input" via the sqlite3_bind_double and "output" via sqlite3_column_double. Therefore the answer should be dependant on whether or not TEXT input is parsed into the appropriate double format. If the text input is converted into the corresponding IEEE754 format, then the output of the inverse conversion (double to text) should also present the same information notwithstanding the fact that +0.0 == -0.0. For example, the statements: select -0.0; select cast(cast('-0.0' as real) as text); both return a text representation '0.0'. From this it is impossible to tell if the intermediate IEEE754 floating point value is -0.0 or +0.0. Testing reveals that the actual intermediate IEEE754 representation is in fact -0.0 Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import apsw >>> db = apsw.Connection('') >>> for row in db.execute('select -0.0, 0.0, -0.0 == 0.0;'): ... print(row, type(row._0), type(row._1), type(row._2)) ... Row(_0=-0.0, _1=0.0, _2=1) <class 'float'> <class 'float'> <class 'int'> I would therefore submit that the conversion from double to text should also produce the same '-0.0' output for -0.0 IEEE754 floats. --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users