public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Erik Brandsberg <[email protected]>
Cc: szy <[email protected]>
Cc: pgsql-sql <[email protected]>
Subject: Re: Inconsistent results for division and multiplication operations
Date: Mon, 25 Nov 2024 11:34:38 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAFcck8EQ3h15-P=Ndt269gE50FDMc=BmWM0iVfUuLbev5HJUbQ@mail.gmail.com>
References: <[email protected]>
	<CAFcck8EQ3h15-P=Ndt269gE50FDMc=BmWM0iVfUuLbev5HJUbQ@mail.gmail.com>

Erik Brandsberg <[email protected]> writes:
> This is a common issue with using floating point math.  You will see the
> same issue with many systems.  Basically, the order of operations can
> trigger very minor differences in results, but if you round the first
> result to the same number of significant digits as the input, it would be
> identical.
> https://learn.microsoft.com/en-us/office/troubleshoot/access/floating-calculations-info

Yeah.  The OP is actually working with PG's "numeric" type, not
floating-point, but the principle is the same.  Some division
results can't be represented exactly in any finite number of
digits, so you get roundoff error.

			regards, tom lane





reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Inconsistent results for division and multiplication operations
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox