| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
|---|---|
| To: | rschaaf(at)commoninf(dot)com | 
| Cc: | 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-23 14:48:03 | 
| Message-ID: | 32478.1427122083@sss.pgh.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-bugs | 
rschaaf(at)commoninf(dot)com writes:
> The result returned by the following query appears to depend on the
> PostgreSQL database version.
> The query is:
> select column1 AS double_value, cast(column1 AS INT) AS int_value
>   from (VALUES (-2.5::double precision),
>                (-1.5::double precision),
>                (-0.5::double precision),
>                (0.5::double precision),
>                (1.5::double precision),
>                (2.5::double precision)) t;
> In PostgreSQL 9.3.5, the query returns:
> double_value, int_value
>   -2.5, -3
>   -1.5, -2
>   -0.5, -1
>   0.5, 1
>   1.5, 2
>   2.5, 3
> PostgreSQL 9.4.1, the query returns:
>   -2.5, -2
>   -1.5, -2
>   -0.5, 0
>   0.5, 0
>   1.5, 2
>   2.5, 2
FWIW, I get the latter behavior (round to nearest even) in all release
branches, and I would say that one is correct.  Not real sure why your
9.3 installation is misbehaving.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jeff Davis | 2015-03-23 20:05:47 | pg_get_constraintdef() doesn't always give an equal constraint | 
| Previous Message | IPN Bala GSS TVL | 2015-03-23 14:12:01 | PL/Proxy compiling error in Postgres 9.4 Development Server on Ubuntu 14.10 |