Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJhg5-0003Y7-Gn for pgsql-sql@arkaria.postgresql.org; Thu, 25 Apr 2019 16:56:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hJhg4-00016G-1t for pgsql-sql@arkaria.postgresql.org; Thu, 25 Apr 2019 16:56:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJhg3-0000vH-L6 for pgsql-sql@lists.postgresql.org; Thu, 25 Apr 2019 16:56:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJhg1-0007xo-7h for pgsql-sql@lists.postgresql.org; Thu, 25 Apr 2019 16:56:50 +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 x3PGukZ6026109; Thu, 25 Apr 2019 12:56:46 -0400 From: Tom Lane To: Max Lipsky cc: pgsql-sql@lists.postgresql.org Subject: Re: Problem in In-reply-to: <2164C531-EAA3-4CAF-996F-FEB0E5F73B32@gmail.com> References: <2164C531-EAA3-4CAF-996F-FEB0E5F73B32@gmail.com> Comments: In-reply-to Max Lipsky message dated "Thu, 25 Apr 2019 16:45:18 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26107.1556211406.1@sss.pgh.pa.us> Date: Thu, 25 Apr 2019 12:56:46 -0400 Message-ID: <26108.1556211406@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Max Lipsky writes: > SELECT acos( > cos(radians(48.9193)) > * cos(radians(48.9193)) > * cos(radians(2.5431) - radians(2.5431)) > + sin(radians(48.9193)) > * sin(radians(48.9193)) > ) as result; > This returned [22003] ERROR: input is out of range Not too surprising, because (at least on my machine) regression=# select cos(radians(48.9193)) regression-# * cos(radians(48.9193)) + sin(radians(48.9193)) regression-# * sin(radians(48.9193)); ?column? -------------------- 1.0000000000000002 (1 row) Problems of this sort are inevitable when working with finite-precision math. https://en.wikipedia.org/wiki/Round-off_error regards, tom lane