Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue - Mailing list pgsql-jdbc

From Vladimir Sitnikov
Subject Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue
Date
Msg-id CAB=Je-H8NiTt_+roUXzv=UiL6QWG-7QzihMVvpXrwyq8FLuo3w@mail.gmail.com
Whole thread Raw
In response to Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-jdbc
Tom>The SQL standard

The documentation says that PostgreSQL implements IEEE Standard 754.

1234567 is exactly representable in IEEE (e.g. see https://www.exploringbinary.com/floating-point-converter/ ),
so I would expect the database should keep the value intact.

1234567 is exactly representable in both float4 and numeric, so it is surprising that 1234567::float4::numeric::text yields 1234570 in PG 12.2

----

In case that matters, pgjdbc does send pass extra_float_digits=2 in the initial packet, then it upgrades to extra_float_digist=3 in case server version is 9.0+
I did try removing that parameter, and it does not resolve 1234567::float4::numeric::text issue

Vladimir

pgsql-jdbc by date:

Previous
From: Tom Lane
Date:
Subject: Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue
Next
From: Tom Lane
Date:
Subject: Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue