Re: BUG #12885: The result of casting a double to an integer depends on the database version

From: Pedro Gimeno <pgsql-004(at)personal(dot)formauri(dot)es>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, rschaaf(at)commoninf(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #12885: The result of casting a double to an integer depends on the database version
Date: 2015-03-25 02:11:51
Message-ID: 55121967.90308@personal.formauri.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Michael Paquier wrote, On 2015-03-25 01:19:
> Hence I'd rather think that patching src/port is the way to go, with
> for example something like the patch attached.

There are some corner cases that that patch does not handle properly,
most notably doubles that would overflow an integer. I suggest the
attached implementation (it's not as a patch, though). I've included a
test suite. The function can deal with non-IEEE floats too, but some of
the tests assume IEEE doubles.

Attachment Content-Type Size
nearest_or_even.c text/x-csrc 1.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2015-03-25 03:26:58 Re: BUG #12885: The result of casting a double to an integer depends on the database version
Previous Message Bruce Momjian 2015-03-25 00:53:42 Re: minor: contrib/btree_gin/btree_gin.c uses DirectFunctionCall3(inet_in,..)