Re: Problem in

Max Lipsky <[email protected]> Fri, 26 Apr 2019 00:08:27 +0300
Newsgroups gmane.comp.db.postgresql.sql
Message-ID <[email protected]>
Hello Tom!

I think is too much for roundoff error

Found funny post about it:
https://randomascii.wordpress.com/2014/10/09/intel-underestimates-error-bounds-by-1-3-quintillion/ <https://randomascii.wordpress.com/2014/10/09/intel-underestimates-error-bounds-by-1-3-quintillion/>
http://notabs.org/fpuaccuracy/index.htm <http://notabs.org/fpuaccuracy/index.htm>



> On 25 Apr 2019, at 19:56, Tom Lane <[email protected]> wrote:
> 
> Max Lipsky <[email protected]> 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