Thread: BUG #4660: float functions return -0

BUG #4660: float functions return -0

From
"ITAGAKI Takahiro"
Date:
The following bug has been logged online:

Bug reference:      4660
Logged by:          ITAGAKI Takahiro
Email address:      itagaki.takahiro@oss.ntt.co.jp
PostgreSQL version: 8.3.3
Operating system:   Fedora 8
Description:        float functions return -0
Details:

Float8 versions of trunc(), ceil() and round() could return -0 on some
version of glibc.

We avoid -0 in float8um (unary minus),
but should we add the same codes in those functions?
There is inconsistency compared with numeric version
of funcs and it is a platform-dependent behavior;
0 is returned there.

postgres=# SELECT pg_catalog.trunc((-0.1)::float8);
 trunc
-------
    -0
(1 row)

postgres=# SELECT pg_catalog.ceil((-0.1)::float8);
 ceil
------
   -0
(1 row)

postgres=# SELECT pg_catalog.round((-0.1)::float8);
 round
-------
    -0
(1 row)

postgres=# select version();
                                              version
----------------------------------------------------------------------------
------------------------
 PostgreSQL 8.3.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.1
20070105 (Red Hat 4.1.1-51)
(1 row)

Re: BUG #4660: float functions return -0

From
Tom Lane
Date:
"ITAGAKI Takahiro" <itagaki.takahiro@oss.ntt.co.jp> writes:
> We avoid -0 in float8um (unary minus),

I wonder why we do that.

            regards, tom lane