Thread: BUG #2153: atan2(0, 0) ERROR: input is out of range on Solaris

BUG #2153: atan2(0, 0) ERROR: input is out of range on Solaris

From
"Norman Young"
Date:
The following bug has been logged online:

Bug reference:      2153
Logged by:          Norman Young
Email address:      nbyoung@westernavionics.com
PostgreSQL version: 8.0.3
Operating system:   Solaris
Description:        atan2(0, 0) ERROR:  input is out of range on Solaris
Details:

Solaris
=======

$ uname -a
SunOS solarishost 5.9 Generic_117171-07 sun4u sparc SUNW,Ultra-60
$ gcc --version
gcc (GCC) 3.3.2
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ psql -h solarishost -U postgres dbname
Welcome to psql 8.0.3, the PostgreSQL interactive terminal.
[snip]
comcube=# SELECT atan2(0, 0);
ERROR:  input is out of range

Linux
=====
$ uname -a
Linux linuxhost 2.6.11-1.1369_FC4smp #1 SMP Thu Jun 2 23:08:39 EDT 2005 i686
i686 i386 GNU/Linux

$ rpm -qi postgresql-server-8.0.3-1
Name        : postgresql-server            Relocations: (not relocatable)
Version     : 8.0.3                             Vendor: Red Hat, Inc.
Release     : 1                             Build Date: Tue 10 May 2005
11:42:55 AM EDT
Install Date: Tue 30 Aug 2005 09:55:42 AM EDT      Build Host:
decompose.build.redhat.com
Group       : Applications/Databases        Source RPM:
postgresql-8.0.3-1.src.rpm
Size        : 9979759                          License: BSD
Signature   : DSA/SHA1, Fri 20 May 2005 01:40:20 PM EDT, Key ID
b44269d04f2a6fd2Packager    : Red Hat, Inc.
<http://bugzilla.redhat.com/bugzilla>
URL         : http://www.postgresql.org/
Summary     : The programs needed to create and run a PostgreSQL server.

$ psql -h linuxhost -U postgres dbname
Welcome to psql 8.0.3, the PostgreSQL interactive terminal.
[snip]
comcube=# SELECT atan2(0, 0);
 atan2
-------
     0
(1 row)

Workaround
==========
CASE WHEN arg1=0 AND arg2=0 THEN 0 ELSE atan2(ar1, arg2)

Re: BUG #2153: atan2(0, 0) ERROR: input is out of range on Solaris

From
Tom Lane
Date:
"Norman Young" <nbyoung@westernavionics.com> writes:
> Description:        atan2(0, 0) ERROR:  input is out of range on Solaris

Actually, I'd argue that it's the Linux atan2() that's broken.  But
in any case, what you're looking at is a difference in the behavior
of the underlying library functions on the two platforms.  We do not
try to second-guess libm ...

            regards, tom lane