agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Max Lipsky <maxlipsky@gmail.com>
Cc: pgsql-sql@lists.postgresql.org
Subject: Re: Problem in
Date: Thu, 25 Apr 2019 12:56:46 -0400
Message-ID: <26108.1556211406@sss.pgh.pa.us> (raw)
In-Reply-To: <2164C531-EAA3-4CAF-996F-FEB0E5F73B32@gmail.com>
References: <2164C531-EAA3-4CAF-996F-FEB0E5F73B32@gmail.com>

Max Lipsky <maxlipsky@gmail.com> 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





view thread (9+ messages)  latest in thread

Message-ID: <26108.1556211406@sss.pgh.pa.us>
Permalink:  ../26108.1556211406@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26108.1556211406@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, maxlipsky@gmail.com, pgsql-sql@lists.postgresql.org
  Subject: Re: Problem in
  In-Reply-To: <26108.1556211406@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox