Inconsistent results for division and multiplication operations

From: szy <598546998(at)qq(dot)com>
To: pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Inconsistent results for division and multiplication operations
Date: 2024-11-25 15:46:28
Message-ID: tencent_59551086059D604A0E8C30A43A934D7D6906@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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(at)qq(dot)com

&nbsp;

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Erik Brandsberg 2024-11-25 15:53:38 Re: Inconsistent results for division and multiplication operations
Previous Message Sam Stearns 2024-10-16 23:07:29 Re: Postgres View DDL