Thread: BUG #2211: select (1::float-1::float)*(-1) = -0 ??

BUG #2211: select (1::float-1::float)*(-1) = -0 ??

From
"Tiago D. J."
Date:
The following bug has been logged online:

Bug reference:      2211
Logged by:          Tiago D. J.
Email address:      tiago@mdtestudio.com.br
PostgreSQL version: 8.1
Operating system:   Slackware 10.2
Description:        select (1::float-1::float)*(-1) = -0 ??
Details:

Hi people,
I think that anything * 0, or 0*anything should be zero.
But run this query :
select (1::float-1::float)*(-1)

it returns -0

Sorry, my english is so poor,
I hope that i'm helping you with this information.

Tiago

Re: BUG #2211: select (1::float-1::float)*(-1) = -0 ??

From
Jaime Casanova
Date:
On 1/25/06, Tiago D. J. <tiago@mdtestudio.com.br> wrote:
>
> The following bug has been logged online:
>
> Bug reference:      2211
> Logged by:          Tiago D. J.
> Email address:      tiago@mdtestudio.com.br
> PostgreSQL version: 8.1
> Operating system:   Slackware 10.2
> Description:        select (1::float-1::float)*(-1) =3D -0 ??
> Details:
>
> Hi people,
> I think that anything * 0, or 0*anything should be zero.
> But run this query :
> select (1::float-1::float)*(-1)
>
> it returns -0
>
> Sorry, my english is so poor,
> I hope that i'm helping you with this information.
>
> Tiago
>

pruebas=3D# select version();
                                         version

---------------------------------------------------------------------------=
---------------
 PostgreSQL 8.1.1 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC)
3.4.2 (mingw-special)
(1 fila)


pruebas=3D# select (1::float-1::float)*(-1);
 ?column?
----------
        0
(1 fila)


This is good for me... maybe a bug already fixed?

--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

Re: BUG #2211: select (1::float-1::float)*(-1) = -0 ??

From
Tom Lane
Date:
"Tiago D. J." <tiago@mdtestudio.com.br> writes:
> But run this query :
> select (1::float-1::float)*(-1)

> it returns -0

AFAIK this is correct behavior per the IEEE floating-point-math spec.

            regards, tom lane