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 1hJhbW-0003MD-1P for pgsql-sql@arkaria.postgresql.org; Thu, 25 Apr 2019 16:52:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hJhbU-0001WX-Q0 for pgsql-sql@arkaria.postgresql.org; Thu, 25 Apr 2019 16:52:08 +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 1hJeh1-0005gc-Fq for pgsql-sql@lists.postgresql.org; Thu, 25 Apr 2019 13:45:39 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJegm-0003a4-DZ for pgsql-sql@lists.postgresql.org; Thu, 25 Apr 2019 13:45:38 +0000 Received: by mail-wm1-x335.google.com with SMTP id 10so9451901wmk.0 for ; Thu, 25 Apr 2019 06:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:message-id:date:to; bh=DIbWwA2vOIjzYGzRRJKNp2ZN3LmZ0xjZbEgAsb46DGA=; b=LWT0BBIYmapPUesr5eD3xTHMn8GNBgrbpFaqQOYE98h8IhdMaSUL6SkfY0Xp6mdp8g oq5bQoSWyt3E+hkYu489Q3XoMMgmAMpaRv4y+Hx8pXseqnP2xbJzSxZ9th7HonFjLZ5N ibGtM6UtOBtu0tP6hrJVT6WcMGsuu2mlJah5mVg0UeX4H4swUDGo/91dSLgdKmggdCFx Ki4EqQyMaiOKOhaPo8tA1JcK7yGAIANX5tKTdgIBZFzNuUtgkPWR/0AFjQo8TXEepU7L yN/GB8YM/HXoWJZQZcNUA2atC0yCAJUJtDyA6UB+DKKchGOvW6yGtxzvWz9MYimugOe/ +MKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:message-id:date:to; bh=DIbWwA2vOIjzYGzRRJKNp2ZN3LmZ0xjZbEgAsb46DGA=; b=TbgEEX0zfd0lznS28179tBc00SmUUZ/kBIoFcY7p+zy+Xvh3Sf8871CccdRTYluZKu hJ+mEbeSK4S/Y2EDTlPWiQ9EkM9ymdL3FCO1GqGXN2UMQAhRpNiHkOcaKD38KTtfdVW/ iYBCV8+nOvLPk3xIxBEcFRgf2BhjFgkBR6iwaW2INi4IVHQAyXXpMuxCZJa3fx1+ejE6 asnEqIJokafva540LRGwIAQn4DiKKWY9TPzltn6lyvQMVfPzPCsK64+FJp8x/62VKpMc Jugb9I2T86CZ94a9L9EvMR6reCP4MsEnldwfdwRvKsVX8o5MOayZpXSNxVRRdIqF5soW aFWQ== X-Gm-Message-State: APjAAAWpF+JK4eVKfTm1zwx3WT9OxY6ogQL+EhkzWDo5AD5NZ+mHOcGv 5zT/MSbK1Fc+ALeaTrdxqLvWTENqA7M= X-Google-Smtp-Source: APXvYqxCGYaceUAtNrmDpYGQfOgRIw7axIfltIrRt5fvY5KWJJ7nxOLL9fjVYGfLS2ZxnuXIJHd06Q== X-Received: by 2002:a1c:4844:: with SMTP id v65mr3609936wma.139.1556199922081; Thu, 25 Apr 2019 06:45:22 -0700 (PDT) Received: from [10.8.1.78] ([196.196.200.52]) by smtp.gmail.com with ESMTPSA id b11sm18398943wru.61.2019.04.25.06.45.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 06:45:21 -0700 (PDT) From: Max Lipsky Content-Type: multipart/alternative; boundary="Apple-Mail=_AE322FA7-B77B-47E4-9AB4-45503A5713C6" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: Problem in Message-Id: <2164C531-EAA3-4CAF-996F-FEB0E5F73B32@gmail.com> Date: Thu, 25 Apr 2019 16:45:18 +0300 To: pgsql-sql@lists.postgresql.org X-Mailer: Apple Mail (2.3445.104.8) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_AE322FA7-B77B-47E4-9AB4-45503A5713C6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi everyone! I found an incomprehensible behavior of some functions in PostgreSQL = 9.5.12 (for 10.6 working good).=20 For example: 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 But this one working good: SELECT acos( cos(radians(48.9192)) * cos(radians(48.9192)) * cos(radians(2.5431) - radians(2.5431)) + sin(radians(48.9192)) * sin(radians(48.9192)) ) as result; The difference is 48.9193 =3D> 48.9192 I did research a bit and found what this query SELECT cos(0.8538028527708621) * cos(0.8538028527708621) + = sin(0.8538028527708621) * sin(0.8538028527708621) as s1; Returned 1.0000000000000002 SELECT cos(0.8538028527708621) * cos(0.8538028527708621) as s1; -- = 0.43180849723816966 SELECT sin(0.8538028527708621) * sin(0.8538028527708621) as s1; -- = 0.5681915027618305 Looks like cos() have scale =3D 17 (sometimes), but sin() have scale 16 P.S. I saw it only in the IntelliJ IDEA console. In the native console = these values will be rounded: SELECT cos(0.8538028527708621) * cos(0.8538028527708621) as s1; s1 ------------------ 0.43180849723817 * * * Best Regards, Max Lipsky --Apple-Mail=_AE322FA7-B77B-47E4-9AB4-45503A5713C6 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Hi = everyone!

I found an = incomprehensible behavior of some functions in PostgreSQL 9.5.12 = (for 10.6 working good). 

For example:

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

But = this one working good:

SELECT =
acos(
cos(radians(48.9192))
* cos(radians(48.9192))
= * cos(radians(2.5431) - radians(2.5431))
= + sin(radians(48.9192))
= * sin(radians(48.9192))
= ) as result;

The = difference is 48.9193 =3D> 48.9192

I did research a bit and found what = this query

SELECT =
cos(0.8538028527708621) * cos(0.8538028527708621) + sin(0.8538028527708621) * sin(0.8538028527708621) as s1;
Returned 1.0000000000000002
SELECT =
cos(0.8538028527708621) * cos(0.8538028527708621) as s1; -- =
0.43180849723816966
SELECT sin(0.8538028527708621) * sin(0.8538028527708621) as s1; = -- = 0.5681915027618305
Looks like cos() have = scale =3D 17 (sometimes), but sin() have scale 16



P.S. I saw it only in = the IntelliJ IDEA console. In the native console these values will be = rounded:

SELECT cos(0.8538028527708621) * cos(0.8538028527708621) as = s1;
        s1
------------------
 0.43180849723817



* * *
Best Regards,
Max Lipsky

= --Apple-Mail=_AE322FA7-B77B-47E4-9AB4-45503A5713C6--