Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1asLJo-0008IS-1x for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Apr 2016 02:23:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1asLJn-0007Vm-Kl for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Apr 2016 02:23:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1asLJl-0007UQ-RL for pgsql-hackers@postgresql.org; Tue, 19 Apr 2016 02:23:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1asLJj-0003ns-3E for pgsql-hackers@postgresql.org; Tue, 19 Apr 2016 02:23:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u3J2MxFF020831; Mon, 18 Apr 2016 22:22:59 -0400 From: Tom Lane To: Noah Misch cc: Michael Paquier , Peter Eisentraut , Robert Haas , Dean Rasheed , "pgsql-hackers@postgresql.org" Subject: Re: [COMMITTERS] pgsql: Add trigonometric functions that work in degrees. In-reply-to: <20160419021144.GA1984253@tornado.leadboat.com> References: <570311F1.6020902@gmx.net> <31479.1460152130@sss.pgh.pa.us> <5714552B.5030001@gmx.net> <12238.1460985466@sss.pgh.pa.us> <20160419021144.GA1984253@tornado.leadboat.com> Comments: In-reply-to Noah Misch message dated "Mon, 18 Apr 2016 22:11:44 -0400" Date: Mon, 18 Apr 2016 22:22:59 -0400 Message-ID: <20830.1461032579@sss.pgh.pa.us> X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Noah Misch writes: > On Mon, Apr 18, 2016 at 09:17:46AM -0400, Tom Lane wrote: >> Given that it's apparently showing the results of asind as NULL ... > I doubt asind is returning NULL. Here's the query, which uses a CASE to > report NULL if asind returns any value not on a whitelist: > SELECT x, > CASE WHEN asind(x) IN (-90,-30,0,30,90) THEN asind(x) END AS asind, > CASE WHEN acosd(x) IN (0,60,90,120,180) THEN acosd(x) END AS acosd, > CASE WHEN atand(x) IN (-45,0,45) THEN atand(x) END AS atand > FROM (VALUES (-1), (-0.5), (0), (0.5), (1)) AS t(x); Oh, duh --- should have checked the query. Yes, the most probable theory must be that it's returning something that's slightly off from the exact value. > I can see the benefit for atand(-0.5) and for atand(0.5), since those are > inexact. Does the CASE gain us anything for asind or acosd? None of these are expected to be inexact. The point of the CASE is to make it obvious if what's returned isn't *exactly* what we expect. We could alternatively set extra_float_digits to its max value and hope that off-by-one-in-the-last-place values would get printed as something visibly different from the exact result. I'm not sure I want to trust that that works reliably; but maybe it would be worth printing the result both ways, just to provide additional info when there's a failure. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers