From: Tom Lane <tgl@sss.pgh.pa.us>
To: levi@leviaul.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16919: Unexpected precision loss in NUMERIC type during text cast, math operations
Date: Wed, 10 Mar 2021 17:00:08 -0500
Message-ID: <2218408.1615413608@sss.pgh.pa.us> (raw)
In-Reply-To: <16919-64fff49d97341054@postgresql.org>
References: <16919-64fff49d97341054@postgresql.org>
PG Bug reporting form <noreply@postgresql.org> writes:
> Simple operations on NUMERIC, supposedly an arbitrary-precision type, are
> having unexpected results for me:
> SELECT '12345678901234567890123456789012345678901234567890'::numeric;
> -- expected 12345678901234567890123456789012345678901234567890
> -- got 12345678901234567890123456789012345678900000000000
[ raised eyebrow... ] Works for me:
regression=# SELECT '12345678901234567890123456789012345678901234567890'::numeric;
numeric
----------------------------------------------------
12345678901234567890123456789012345678901234567890
(1 row)
I'm wondering which compiler and what build options you used.
Also, your reference to mpz makes me doubt that this is a stock
version of Postgres, so maybe you just have a home-grown bug.
(There are some arbitrary decisions about precision of the results
of numeric division, as well as the transcendental functions.
But plain addition and multiplication should be exact, and of course
just reading out a literal certainly should be.)
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, levi@leviaul.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16919: Unexpected precision loss in NUMERIC type during text cast, math operations
In-Reply-To: <2218408.1615413608@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