From: | Max Lipsky <maxlipsky(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)lists(dot)postgresql(dot)org |
Subject: | Problem in |
Date: | 2019-04-25 13:45:18 |
Message-ID: | 2164C531-EAA3-4CAF-996F-FEB0E5F73B32@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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 => 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 = 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-04-25 16:56:46 | Re: Problem in |
Previous Message | Tom Lane | 2019-04-22 19:48:38 | Re: xpath insert unexpected newlines |