pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15434: NUMERIC without any precision or scale truncates scale to 16 digits
3+ messages / 3 participants
[nested] [flat]
* BUG #15434: NUMERIC without any precision or scale truncates scale to 16 digits
@ 2018-10-16 09:35 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: PG Bug reporting form @ 2018-10-16 09:35 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: parihaaraka@gmail.com
The following bug has been logged on the website:
Bug reference: 15434
Logged by: Andrey L
Email address: parihaaraka@gmail.com
PostgreSQL version: 10.5
Operating system: Ubuntu 16.04
Description:
# select
1800000000000000001::numeric / (10^18)::numeric truncated, -- truncates to
16 digits after decimal point
1800000000000000001::numeric(48,18) / (10^18)::numeric correct,
1800000000000000001::numeric / (10^18)::numeric * (10^18)::numeric
to_be_sure;
truncated | correct | to_be_sure
--------------------+----------------------+--------------------------------------
1.8000000000000000 | 1.800000000000000001 |
1800000000000000000.0000000000000000
(1 row)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #15434: NUMERIC without any precision or scale truncates scale to 16 digits
@ 2018-10-16 11:30 Andrew Gierth <andrew@tao11.riddles.org.uk>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Gierth @ 2018-10-16 11:30 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; parihaaraka@gmail.com
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:
PG> 1800000000000000001::numeric / (10^18)::numeric truncated, --
PG> truncates to 16 digits after decimal point
It has to truncate it _somewhere_, because otherwise 1::numeric / 3
would be infinitely long...
The choice that numeric division actually makes is to produce a result
with at least 16 significant figures, but also with at least as many
decimal places as the display scale of either of the inputs.
--
Andrew (irc:RhodiumToad)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #15434: NUMERIC without any precision or scale truncates scale to 16 digits
@ 2018-10-16 12:25 Andrey <parihaaraka@gmail.com>
parent: Andrew Gierth <andrew@tao11.riddles.org.uk>
0 siblings, 0 replies; 3+ messages in thread
From: Andrey @ 2018-10-16 12:25 UTC (permalink / raw)
To: andrew@tao11.riddles.org.uk; +Cc: pgsql-bugs@lists.postgresql.org
вт, 16 окт. 2018 г. в 14:30, Andrew Gierth <andrew@tao11.riddles.org.uk>:
> >>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:
>
> PG> 1800000000000000001::numeric / (10^18)::numeric truncated, --
> PG> truncates to 16 digits after decimal point
>
> It has to truncate it _somewhere_, because otherwise 1::numeric / 3
> would be infinitely long...
>
> The choice that numeric division actually makes is to produce a result
> with at least 16 significant figures, but also with at least as many
> decimal places as the display scale of either of the inputs.
>
> --
> Andrew (irc:RhodiumToad)
>
It looks like precision does matters.
man: "...up to the implementation limit on precision".
Why we don't want to decrease scale, but we decrease precision without any
problems?
Regards,
Andrey L
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2018-10-16 12:25 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-16 09:35 BUG #15434: NUMERIC without any precision or scale truncates scale to 16 digits PG Bug reporting form <noreply@postgresql.org>
2018-10-16 11:30 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
2018-10-16 12:25 ` Andrey <parihaaraka@gmail.com>
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