Re: BUG #1577: round(dp) function does not round to nearest integer properly

From: Russell Smith <russell(at)pws(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Roman Schayuk" <rschayuk(at)rogers(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1577: round(dp) function does not round to nearest integer properly
Date: 2005-04-10 22:45:13
Message-ID: 200504110845.14546.russell@pws.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, 11 Apr 2005 05:57 am, Tom Lane wrote:
> "Roman Schayuk" <rschayuk(at)rogers(dot)com> writes:
> > gap=> select round(42.5);
> > round
> > -------
> > 42
> > (1 row)
> > Result has to be 43
>
> No, the above is perfectly correct and in fact required by the IEEE
> standard for floating-point arithmetic (because round-to-nearest-even
> is the default rounding mode).
>
That is rounding of unrepresentable numbers, is it not? at least
http://www.ee.ucla.edu/~vandenbe/103/flpt.pdf suggests that to me as I couldn't find
the IEEE spec about this. I'm sure somebody has it at hand, but I don't.

Either way 8.0.1 round differently;

test=# select version();
version
--------------------------------------------------------------------------------------------------------------------------
PostgreSQL 8.0.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
(1 row)

test=# select round(42.5);
round
-------
43
(1 row)

test=# select round(42.5,0);
round
-------
43
(1 row)

> If anything needs to be changed here, it's the behavior of round(numeric).
>
So I would say that the round behaviour has changed as Tom has suggested, but which is correct?

7.2, or 8.0?

Regards

Russell Smith

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2005-04-10 23:32:58 Re: problem with Win1251 (Cyrillic)
Previous Message Bruno Wolff III 2005-04-10 22:23:16 Re: BUG #1581: Problem with capitalised DB names...