Re: BUG #13885: float->string conversion loses precision server-side on JDBC connection - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #13885: float->string conversion loses precision server-side on JDBC connection
Date
Msg-id 11278.1453738005@sss.pgh.pa.us
Whole thread Raw
In response to BUG #13885: float->string conversion loses precision server-side on JDBC connection  (xtracoder@gmail.com)
Responses Re: BUG #13885: float->string conversion loses precision server-side on JDBC connection
List pgsql-bugs
xtracoder@gmail.com writes:
> I have a PostgreSQL function, which accepts JSON, performs some processing,
> and returns JSON. Something strange is happening when calling stored
> procedure from Java application - float->string conversion is incorrect.

I don't think it's "incorrect".  I believe the displayed difference here
is because the JDBC driver sets extra_float_digits to 3 or so.
Compare this in psql:

regression=# do $$ declare x float := 4.1; begin raise notice 'x = %', x; end$$;
NOTICE:  x = 4.1
DO
regression=# set extra_float_digits = 3;
SET
regression=# do $$ declare x float := 4.1; begin raise notice 'x = %', x; end$$;
NOTICE:  x = 4.09999999999999964
DO

The uglier-looking number is a more precise representation of the actual
float4 value.

            regards, tom lane

pgsql-bugs by date:

Previous
From: kunschikov@gmail.com
Date:
Subject: BUG #13888: pg_dump write error
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #13888: pg_dump write error