From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: slawomir.chodnicki@gmail.com
Subject: BUG #15925: Loss of precision converting money to numeric
Date: Fri, 26 Jul 2019 07:39:17 +0000
Message-ID: <15925-da9953e2674bb5c8@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15925
Logged by: Slawomir Chodnicki
Email address: slawomir.chodnicki@gmail.com
PostgreSQL version: 11.4
Operating system: Linux
Description:
As per documentation converting a money value to numeric does not lose
precision. In general that is the case:
select '8547758.07'::money, '8547758.07'::money::numeric(30,2);
money |numeric |
-------------|----------|
$8,547,758.07|8547758.07|
During my testing I found unexpected results for the min and max value of
the money type.
select '-92233720368547758.08'::money,
'-92233720368547758.08'::money::numeric(30,2);
money |numeric |
---------------------------|---------------------|
-$92,233,720,368,547,758.08|-92233720368547758.00|
Note that the cent value is gone after converting to numeric.
Same issue for the max value:
money |numeric |
--------------------------|--------------------|
$92,233,720,368,547,758.07|92233720368547758.00|
Best Wishes
Slawo
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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, slawomir.chodnicki@gmail.com
Subject: Re: BUG #15925: Loss of precision converting money to numeric
In-Reply-To: <15925-da9953e2674bb5c8@postgresql.org>
* 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