Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version
Date
Msg-id CAB7nPqQL4wsAX3E9gjQtOetgYQ8w7kWtFQQ3ctJfCc3PONjprA@mail.gmail.com
Whole thread Raw
In response to Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List pgsql-bugs
On Thu, Mar 26, 2015 at 9:19 AM, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
>>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
>
>  Tom> BTW, if memory serves we also have a pretty lazy rounding
>  Tom> implementation for the numeric datatype.  I wonder if now would be
>  Tom> a good time to upgrade that to be round-to-nearest-even as well.
>
> A data point: there have been occasional complaints on IRC about the
> fact that numeric rounding is not round-to-even, but obviously it's
> harder to tell if anyone is relying on the current behavior.

Indeed...
=# select column1 AS double_value, cast(column1 AS INT) AS int_value
  FROM (VALUES (-2.5::numeric),
         (-1.5::numeric),
         (-0.5::numeric),
         (0.5::numeric),
         (1.5::numeric),
         (2.5::numeric)) t;
 double_value | int_value
--------------+-----------
         -2.5 |        -3
         -1.5 |        -2
         -0.5 |        -1
          0.5 |         1
          1.5 |         2
          2.5 |         3
(6 rows)

Tom, if there is a patch showing up soon, would you integrate it? I
imagine that it would be good to have the same behavior for a maximum
of datatypes in 9.5 now that src/port/rint.c is more compliant.
Regards,
--
Michael

pgsql-bugs by date:

Previous
From: Andrew Gierth
Date:
Subject: Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version
Next
From: Tom Lane
Date:
Subject: Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version