Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aNjfy-0003Qi-MR for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Jan 2016 16:07:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aNjfx-000781-MJ for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Jan 2016 16:07:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aNjfK-0006Qf-VT for pgsql-bugs@postgresql.org; Mon, 25 Jan 2016 16:06:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aNjfE-0004sI-Ex for pgsql-bugs@postgresql.org; Mon, 25 Jan 2016 16:06:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u0PG6jT4011279; Mon, 25 Jan 2016 11:06:45 -0500 From: Tom Lane To: xtracoder@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13885: float->string conversion loses precision server-side on JDBC connection In-reply-to: <20160124202951.2537.67173@wrigleys.postgresql.org> References: <20160124202951.2537.67173@wrigleys.postgresql.org> Comments: In-reply-to xtracoder@gmail.com message dated "Sun, 24 Jan 2016 20:29:51 +0000" Date: Mon, 25 Jan 2016 11:06:45 -0500 Message-ID: <11278.1453738005@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs