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 1oj4Ud-0000sE-JO for pgsql-general@arkaria.postgresql.org; Thu, 13 Oct 2022 20:07:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oj4Uc-0003Fj-Bx for pgsql-general@arkaria.postgresql.org; Thu, 13 Oct 2022 20:07:46 +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 1oj4Uc-0003FO-0e for pgsql-general@lists.postgresql.org; Thu, 13 Oct 2022 20:07:46 +0000 Received: from mout-u-204.mailbox.org ([80.241.59.204]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oj4UZ-0000ox-Dx for pgsql-general@postgresql.org; Thu, 13 Oct 2022 20:07:44 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4MpLCq225lz9sTD; Thu, 13 Oct 2022 22:07:35 +0200 (CEST) Date: Thu, 13 Oct 2022 22:07:33 +0200 (CEST) From: Erik Wienhold To: Tom Lane Cc: pgsql-general Message-ID: <523542390.245047.1665691653665@office.mailbox.org> In-Reply-To: <979360.1665681418@sss.pgh.pa.us> References: <12a40226-70ac-3a3b-3d3a-fdaf9e32d312@aklaver.com> <603008316.190107.1665680007674@office.mailbox.org> <979360.1665681418@sss.pgh.pa.us> Subject: Re: Exponentiation confusion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 13/10/2022 19:16 CEST Tom Lane wrote: > > Erik Wienhold writes: > > On 13/10/2022 18:20 CEST Adrian Klaver wrote: > >> select power(10, -18::numeric); > >> power > >> -------------------- > >> 0.0000000000000000 > >> > >> Why is the cast throwing off the result? > > > Calling power(numeric, numeric) is what I expect in that case instead of > > downcasting the exponent argument to double precision, thus losing precision. > > An inexact result isn't surprising, but it shouldn't be *that* inexact. Ah, now I see the problem. I saw a bunch of zeros but not that it's *all* zeros. Nevermind. -- Erik