Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zqmzc-0002jh-RU for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Oct 2015 18:59:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zqmzb-0004Zo-Rm for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Oct 2015 18:59:39 +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) (envelope-from ) id 1ZqmyJ-00032Y-9z for pgsql-hackers@postgresql.org; Mon, 26 Oct 2015 18:58:19 +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) (envelope-from ) id 1ZqmyG-0000mo-Kz for pgsql-hackers@postgresql.org; Mon, 26 Oct 2015 18:58:18 +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 t9QIw9cR032498; Mon, 26 Oct 2015 14:58:09 -0400 From: Tom Lane To: Dean Rasheed cc: Emre Hasegeli , PostgreSQL Hackers Subject: Re: Proposal: Trigonometric functions in degrees In-reply-to: References: <26314.1445869112@sss.pgh.pa.us> Comments: In-reply-to Dean Rasheed message dated "Mon, 26 Oct 2015 18:47:31 -0000" Date: Mon, 26 Oct 2015 14:58:09 -0400 Message-ID: <32497.1445885889@sss.pgh.pa.us> X-Pg-Spam-Score: -1.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 Dean Rasheed writes: > On 26 October 2015 at 14:18, Tom Lane wrote: >> ... but having said that, your argument here is faulty, because 0.9 >> in itself is not exactly representable in binary. You'd be relying >> on roundoff happening in the right direction to get exact answers >> from such calculations, for just the same reasons that sind() can't be >> just "sin(x * scalefactor)" if you want exact-where-possible results. > It would be relying on the things like the following being exactly true: > 45 / 0.9 = 50 > 50 * 0.9 = 45 > 90 / 0.9 = 100 > 100 * 0.9 = 90 > which they are on my machine. I thought that this was guaranteed in > IEEE floating point arithmetic, since one of the inputs and the result > are exactly representable, and the result is guaranteed to be within > 0.5ulp. I'm curious now though. Are there any platforms on which the > above aren't exactly true? Possibly, but the bigger picture is you're ignoring other cases, such as regression=# select 30 / 0.9; ?column? --------------------- 33.3333333333333333 (1 row) which is problematic since sin(30 degrees) = 0.5 is one of the cases one would like to be exact. (Actually I guess this example shows that implementing sind in terms of sing would be imprecise, but I'm sure the reverse holds for some other special angles.) 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