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

From: Xtra Coder <xtracoder(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13885: float->string conversion loses precision server-side on JDBC connection
Date: 2016-01-25 17:47:04
Message-ID: CAL2enjKTr_g8hqa6maJy3PVUF5dw4pUPP8JvZa1Mq0cDD55pwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Yes, this is not bug in terms of 'float->string' convertion - people in
other forum also pointed out to JDBC, "extra_float_digits" and consequences.

On Mon, Jan 25, 2016 at 7:06 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> xtracoder(at)gmail(dot)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
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Randy Westlund 2016-01-25 18:48:25 Re: BUG #13886: When INSERT ON CONFLICT DO UPDATE updates, it returns INSERT rather than UPDATE
Previous Message David G. Johnston 2016-01-25 17:46:28 Re: BUG #13884: array_to_json() works incorrectly for non-0-based arrays