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 1jjYS2-0000ZL-Fv for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jun 2020 01:25:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jjYS1-0001vj-Cz for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jun 2020 01:25:45 +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 1jjYS1-0001va-66 for pgsql-hackers@lists.postgresql.org; Fri, 12 Jun 2020 01:25:45 +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 1jjYRz-0000Sh-2f for pgsql-hackers@lists.postgresql.org; Fri, 12 Jun 2020 01:25:44 +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 05C1Pf4L607043; Thu, 11 Jun 2020 21:25:41 -0400 From: Tom Lane To: =?UTF-8?Q?Darafei_=22Kom=D1=8Fpa=22_Praliaskouski?= cc: PostgreSQL Developers Subject: Re: exp() versus the POSIX standard In-reply-to: References: <582552.1591917752@sss.pgh.pa.us> <583847.1591919809@sss.pgh.pa.us> Comments: In-reply-to =?UTF-8?Q?Darafei_=22Kom=D1=8Fpa=22_Praliaskouski?= message dated "Fri, 12 Jun 2020 03:36:26 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <607041.1591925141.1@sss.pgh.pa.us> Date: Thu, 11 Jun 2020 21:25:41 -0400 Message-ID: <607042.1591925141@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?UTF-8?Q?Darafei_=22Kom=D1=8Fpa=22_Praliaskouski?= writes: > I've had the same issue with multiplying two tiny numbers. Select > 2e-300::float * 2e-300::float gives an underflow, and it is not a wanted > thing. This looks like handmade implementation of IEEE754's underflow > exception that should be an optional return flag in addition to well > defined number, but became a stop-the-world exception instead. Solving that problem is very far outside the scope of what I'm interested in here. I think that we'd probably regret it if we try to support IEEE subnormals, for example --- I know that all modern hardware is probably good with those, but I'd bet against different platforms' libc functions all behaving the same. I don't see a sane way to offer user control over whether we throw underflow errors or not, either. (Do you really want "+" to stop being immutable?) The darker corners of IEEE754, like inexactness exceptions, are even less likely to be implemented consistently everywhere. regards, tom lane