BUG #19101: Ceil on BIGINT could lost precision in decil function - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19101: Ceil on BIGINT could lost precision in decil function
Date
Msg-id 19101-8f44b0e27aa65d40@postgresql.org
Whole thread Raw
Responses Re: BUG #19101: Ceil on BIGINT could lost precision in decil function
Re: BUG #19101: Ceil on BIGINT could lost precision in decil function
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      19101
Logged by:          Jason Smith
Email address:      dqetool@126.com
PostgreSQL version: 18.0
Operating system:   Ubuntu 22.04
Description:

I try to store a large number in `BIGINT` and run  `ceil(c1)` command.
However, the result lost some precision due to calling `decil` function.
```sql
CREATE TABLE t1 (c1 BIGINT);
INSERT INTO t1 VALUES (4854233034440979799);
-- dceil
SELECT ceil(c1) FROM t1; -- {4.854233034440979e+18}
```
The original number is expected to return. In this case, calling
numeric_ceil function may be proper, and I try the following case.
```sql
CREATE TABLE t1 (c1 DECIMAL(20,0));
INSERT INTO t1 VALUES (4854233034440979799);
-- numeric_ceil
SELECT ceil(c1) FROM t1; -- {4854233034440979799}
```


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19100: Different column type between partitioned table and detached pending partition table make errors
Next
From: Laurenz Albe
Date:
Subject: Re: BUG #19101: Ceil on BIGINT could lost precision in decil function