Inconsistent results for division and multiplication operations

szy <598546998@qq.com>

From: szy <598546998@qq.com>
To: pgsql-sql <pgsql-sql@lists.postgresql.org>
Date: 2024-11-25T15:46:28Z
Lists: pgsql-sql
Hi PostgreSQL community,


I have observed inconsistent results when performing division and multiplication operations in PostgreSQL.


postgres=# select 1.003/1.002*5.01;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;?column?
--------------------------
&nbsp;5.0149999999999999999806&nbsp;&nbsp;
(1 row)


postgres=# select 1.003*5.01/1.002;
&nbsp; &nbsp; &nbsp; ?column?
--------------------
&nbsp;5.0150000000000000
(1 row)


However, the expected result should be consistent for both queries. The actual results differ





szy
598546998@qq.com



&nbsp;