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

Started by Tiago Daniel Jacobsabout 20 years ago3 messagesbugs
Jump to latest
#1Tiago Daniel Jacobs
tiago@mdtestudio.com.br

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

#2Jaime Casanova
jcasanov@systemguards.com.ec
In reply to: Tiago Daniel Jacobs (#1)
Re: BUG #2211: select (1::float-1::float)*(-1) = -0 ??

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) = -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=# 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=# 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 ;)

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tiago Daniel Jacobs (#1)
Re: BUG #2211: select (1::float-1::float)*(-1) = -0 ??

"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