From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dave Cramer <pg@fastcrypt.com>
Cc: Timo Nentwig <postgres@nentwig.biz>
Cc: List <pgsql-jdbc@postgresql.org>
Subject: Re: float8 transmitted in ascii
Date: Wed, 29 Apr 2015 16:59:52 -0700
Message-ID: <35729.1430351992@sss.pgh.pa.us> (raw)
In-Reply-To: <CADK3HHJFnXUiU+gWAfGvVCe2Xu6sN_QNZdxjKaFAVGGzoxMWXQ@mail.gmail.com>
References: <alpine.LNX.2.03.1504291738060.41809@nentwig.biz>
<CADK3HHJFnXUiU+gWAfGvVCe2Xu6sN_QNZdxjKaFAVGGzoxMWXQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Dave Cramer <pg@fastcrypt.com> writes:
> If I understand you correctly in java you did:
> select 47.88::DOUBLE PRECISION,
> (47.88::DOUBLE PRECISION)::text,
> (47.88::DOUBLE PRECISION)::numeric,
> replace((47.88::DOUBLE PRECISION)::text, '.', ',');
> and the two numeric values are correct, but the text values are wrong ?
extra_float_digits explains it all, I'm sure.
regression=# select 47.88::DOUBLE PRECISION,
(47.88::DOUBLE PRECISION)::text,
(47.88::DOUBLE PRECISION)::numeric,
replace((47.88::DOUBLE PRECISION)::text, '.', ',');
float8 | text | numeric | replace
--------+-------+---------+---------
47.88 | 47.88 | 47.88 | 47,88
(1 row)
regression=# set extra_float_digits = 3;
SET
regression=# select 47.88::DOUBLE PRECISION,
(47.88::DOUBLE PRECISION)::text,
(47.88::DOUBLE PRECISION)::numeric,
replace((47.88::DOUBLE PRECISION)::text, '.', ',');
float8 | text | numeric | replace
---------------------+---------------------+---------+---------------------
47.8800000000000026 | 47.8800000000000026 | 47.88 | 47,8800000000000026
(1 row)
regards, tom lane
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: tgl@sss.pgh.pa.us, pg@fastcrypt.com, postgres@nentwig.biz
Subject: Re: float8 transmitted in ascii
In-Reply-To: <35729.1430351992@sss.pgh.pa.us>
References: <alpine.LNX.2.03.1504291738060.41809@nentwig.biz> <CADK3HHJFnXUiU+gWAfGvVCe2Xu6sN_QNZdxjKaFAVGGzoxMWXQ@mail.gmail.com> <35729.1430351992@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox