Re: float8 transmitted in ascii

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: Timo Nentwig <postgres(at)nentwig(dot)biz>, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: float8 transmitted in ascii
Date: 2015-04-29 23:59:52
Message-ID: 35729.1430351992@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Dave Cramer <pg(at)fastcrypt(dot)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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Timo Nentwig 2015-04-30 15:36:27 Re: float8 transmitted in ascii
Previous Message Dave Cramer 2015-04-29 22:51:34 Re: float8 transmitted in ascii