Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oj3dJ-0004Qk-FO for pgsql-general@arkaria.postgresql.org; Thu, 13 Oct 2022 19:12:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oj3dI-000818-Dj for pgsql-general@arkaria.postgresql.org; Thu, 13 Oct 2022 19:12:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oj3dI-0007zy-3a for pgsql-general@lists.postgresql.org; Thu, 13 Oct 2022 19:12:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oj3dF-0000OD-Uz for pgsql-general@postgresql.org; Thu, 13 Oct 2022 19:12:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 29DJCVHr1064008; Thu, 13 Oct 2022 15:12:31 -0400 From: Tom Lane To: Dean Rasheed cc: Erik Wienhold , Adrian Klaver , pgsql-general Subject: Re: Exponentiation confusion In-reply-to: References: <12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com> <603008316.190107.1665680007674@office.mailbox.org> <979360.1665681418@sss.pgh.pa.us> Comments: In-reply-to Dean Rasheed message dated "Thu, 13 Oct 2022 20:07:08 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1064006.1665688351.1@sss.pgh.pa.us> Date: Thu, 13 Oct 2022 15:12:31 -0400 Message-ID: <1064007.1665688351@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dean Rasheed writes: > The most obvious thing to do is to try to make power_var_int() choose > the same result rscale as power_var() so that the results are > consistent regardless of whether the exponent is an integer. Yeah, I think we should try to end up with that. > It's worth noting, however, that that will cause in a *reduction* in > the output rscale rather than an increase in some cases, since the > power_var_int() code path currently always chooses an rscale of at > least 16, whereas the other code path in power_var() uses the rscales > of the 2 inputs, and produces a minimum of 16 significant digits, > rather than 16 digits after the decimal point. Right. I think this is not bad though. In a lot of cases (such as the example here) the current behavior is just plastering on useless zeroes. regards, tom lane