PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID15812
PG Version11.3
OSWindows/Linux
Opened2019-05-17 15:46:17+00
Reported byKaleb Akalework
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      15812
Logged by:          Kaleb Akalework
Email address:      (redacted)
PostgreSQL version: 11.3
Operating system:   Windows/Linux
Description:        

I have a need to divide a big number numeric(20) by 10000000000 to feed it
into a floor function. The division operation rounds up the number which
causes problems. I need the division to just divide the number without
rounding up or down. For my purposes 3691635539999999999/10000000000 should
return 369163553.9999999999 not 369163554. This happens if the data is
retrieved from a column. Below are queries to reproduce the problem

create table test_table
(
    REQUEST_UUID varchar(50) not null,
    BIG_NUM numeric(20,0) not null
);

INSERT INTO test_table (REQUEST_UUID, BIG_NUM) values ('TEST',
3691635539999999999);
INSERT INTO test_table (REQUEST_UUID, BIG_NUM) values('TEST',
3691635530099999999);
INSERT INTO test_table (REQUEST_UUID, BIG_NUM) values('TEST',
3691635530999999999);

SELECT BIG_NUM, FLOOR(BIG_NUM/10000000000),  BIG_NUM/10000000000 from
test_table;

The following is the result of the above select. you can see that column 2
for first row was rounded up.

"3691635539999999999"	"369163554"	"369163554.00000000"
"3691635530099999999"	"369163553"	"369163553.01000000"
"3691635530999999999"	"369163553"	"369163553.10000000"

Messages

DateAuthorSubject
2019-05-17 15:46:17+00PG Bug reporting formBUG #15812: Select statement of a very big number, with a division operator seems to round up.
2019-05-17 16:02:11+00Alvaro HerreraRe: BUG #15812: Select statement of a very big number, with a division operator seems to round up.
2019-05-17 16:10:52+00Kaleb AkaleworkRE: BUG #15812: Select statement of a very big number, with a division operator seems to round up.
2019-05-17 16:23:22+00Andres FreundRe: BUG #15812: Select statement of a very big number, with a division operator seems to round up.
2019-05-17 16:23:59+00"David G(dot) Johnston"Re: BUG #15812: Select statement of a very big number, with a division operator seems to round up.
2019-05-17 16:24:15+00Andres FreundRe: BUG #15812: Select statement of a very big number, with a division operator seems to round up.
2019-05-17 16:36:19+00Kaleb AkaleworkRE: BUG #15812: Select statement of a very big number, with a division operator seems to round up.
2019-05-17 18:02:52+00Dean RasheedRe: BUG #15812: Select statement of a very big number, with a division operator seems to round up.
2019-05-17 21:34:28+00Andrew GierthRe: BUG #15812: Select statement of a very big number, with a division operator seems to round up.