Re: BUG #18951: Precision loss in inner join while using SUM aggregate function

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: bingyanli@email.ncu.edu.cn
Cc: pgsql-bugs@lists.postgresql.org
Date: 2025-06-08T15:50:21Z
Lists: pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> -- judgement: s1 = s2 + s3, However, s2 is not correctly computed

[ shrug... ] If you are expecting exact results, don't use
floating-point arithmetic (ie, use "numeric" not "double precision").
This example, which will result in adding values of enormously
different magnitudes in various orders, is tailor-made to
exhibit roundoff error.

https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT

			regards, tom lane