Re: [BUGS] BUG #4660: float functions return -0

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [BUGS] BUG #4660: float functions return -0
Date: 2009-02-17 03:32:13
Message-ID: 25418.1234841533@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
> We already have some codes to avoid -0 float8um (unary minus),
> but there are no protection in trunc(), ceil() and round() at least.

I looked into the CVS history to find out when the anti-minus-zero code
got put into float8um. It seems to have been done by Tom Lockhart here:

http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/float.c.diff?r1=1.13;r2=1.14

The CVS commit message says
Check for zero in unary minus floating point code (IEEE allows an
explicit negative zero which looks ugly in a query result!).
along with some other unrelated changes. I can find no evidence in the
mailing list archives that there was any discussion about the point,
so I think Tom did that on his own authority.

I'm of the opinion that minus zero was put into the IEEE floating point
standard by people who know a great deal more about the topic than
anyone on this list does, and that we do not have the expertise to be
second-guessing how it should work. Not long ago we took out code that
was interfering with spec-compliant treatment of IEEE infinity; I think
we should take out this code too.

Yes, it will be platform dependent, because various platforms get the
IEEE spec wrong to some degree, but so what? This is hardly the only
platform dependence of that kind.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kopljan Michael 2009-02-17 07:27:02 could not write block
Previous Message ITAGAKI Takahiro 2009-02-17 01:14:05 Re: [BUGS] BUG #4660: float functions return -0

Browse pgsql-hackers by date

  From Date Subject
Next Message KaiGai Kohei 2009-02-17 03:47:32 Re: SE-PostgreSQL and row level security
Previous Message KaiGai Kohei 2009-02-17 03:03:53 Re: SE-PostgreSQL and row level security