BUG #19101: Ceil on BIGINT could lost precision in decil function

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: dqetool(at)126(dot)com
Subject: BUG #19101: Ceil on BIGINT could lost precision in decil function
Date: 2025-11-02 15:16:09
Message-ID: 19101-8f44b0e27aa65d40@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19101
Logged by: Jason Smith
Email address: dqetool(at)126(dot)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}
```

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Laurenz Albe 2025-11-02 16:31:29 Re: BUG #19101: Ceil on BIGINT could lost precision in decil function
Previous Message PG Bug reporting form 2025-11-01 18:36:26 BUG #19100: Different column type between partitioned table and detached pending partition table make errors