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 1jjX46-0006MK-9L for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jun 2020 23:56:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jjX42-0001kj-80 for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jun 2020 23:56:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjX42-0001kb-0w for pgsql-hackers@lists.postgresql.org; Thu, 11 Jun 2020 23:56:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjX3z-000153-Lh for pgsql-hackers@lists.postgresql.org; Thu, 11 Jun 2020 23:56:53 +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 05BNuni2583848 for ; Thu, 11 Jun 2020 19:56:49 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: Re: exp() versus the POSIX standard In-reply-to: <582552.1591917752@sss.pgh.pa.us> References: <582552.1591917752@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 11 Jun 2020 19:22:32 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <583846.1591919809.1@sss.pgh.pa.us> Date: Thu, 11 Jun 2020 19:56:49 -0400 Message-ID: <583847.1591919809@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > The POSIX standard says this about the exp(3) function: > If x is -Inf, +0 shall be returned. > At least on my Linux box, our version does no such thing: > regression=# select exp('-inf'::float8); > ERROR: value out of range: underflow Now that I look, power() has similar issues: regression=# select power('1.1'::float8, '-inf'); ERROR: value out of range: underflow regression=# select power('0.1'::float8, 'inf'); ERROR: value out of range: underflow regression=# select power('-inf'::float8, '-3'); ERROR: value out of range: underflow regression=# select power('-inf'::float8, '-4'); ERROR: value out of range: underflow contradicting POSIX which says For |x| > 1, if y is -Inf, +0 shall be returned. For |x| < 1, if y is +Inf, +0 shall be returned. For y an odd integer < 0, if x is -Inf, -0 shall be returned. For y < 0 and not an odd integer, if x is -Inf, +0 shall be returned. regards, tom lane