pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16755: A specification or a bug? Digit drop on CAST from DOUBLE PRECISION to NUMERIC.
2+ messages / 2 participants
[nested] [flat]

* BUG #16755: A specification or a bug? Digit drop on CAST from DOUBLE PRECISION to NUMERIC.
@ 2020-12-01 07:07  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2020-12-01 07:07 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: hisanori.kobayashi.bp@nttdata.com

The following bug has been logged on the website:

Bug reference:      16755
Logged by:          Kobayashi Hisanori
Email address:      hisanori.kobayashi.bp@nttdata.com
PostgreSQL version: 12.4
Operating system:   Windows 10
Description:        

Is this a specification? Or is it a bug?
In PostgreSQL 12.4 for Windows.

It would be understandable if the CAST from NUMERIC to DOUBLE PRECISION
would digit drop, but I don't know if it's a specification or a bug to digit
drop on CAST from DOUBLE PRECISION to NUMERIC. (translated by DeepL)

----- 
postgres=> select (123456789012345::double precision * 11) ;
     ?column?
------------------
 1.358024679135795e+15                 <-- *** No Problem(No digit drop)

postgres=> select (123456789012345::double precision * 11)::numeric ;
     numeric
------------------
 1358024679135800                      <-- *** Digit drop
-----



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #16755: A specification or a bug? Digit drop on CAST from DOUBLE PRECISION to NUMERIC.
@ 2020-12-01 15:24  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2020-12-01 15:24 UTC (permalink / raw)
  To: hisanori.kobayashi.bp@nttdata.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> It would be understandable if the CAST from NUMERIC to DOUBLE PRECISION
> would digit drop, but I don't know if it's a specification or a bug to digit
> drop on CAST from DOUBLE PRECISION to NUMERIC. (translated by DeepL)

float8_numeric() only converts DBL_DIG decimal digits.  We have had
discussions in the past about changing that, but so far the answer
has been "no".  You have to remember that digits beyond DBL_DIG
are unreliable ... so sometimes this would make things better, but
other times it would make things worse.

If you want something that behaves like the textual display
of float8, you can always do float8value::text::numeric.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-12-01 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01 07:07 BUG #16755: A specification or a bug? Digit drop on CAST from DOUBLE PRECISION to NUMERIC. PG Bug reporting form <noreply@postgresql.org>
2020-12-01 15:24 ` Tom Lane <tgl@sss.pgh.pa.us>

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