Skip site navigation (1) Skip section navigation (2)

Re: some errors and/or bugs?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "He Weiping(Laser Henry)" <laser(at)zhengmai(dot)com(dot)cn>
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: some errors and/or bugs?
Date: 2000-12-19 01:02:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-docs
"He Weiping(Laser Henry)" <laser(at)zhengmai(dot)com(dot)cn> writes:
> laser_zh=# select round(42.5);
>  round
> -------
>     42
> (1 row)
> is it correct? I think result should be 43.

It's correct, if the underlying float arithmetic is IEEE-compliant.
Rounding for exact half-integral values is supposed to be "round to
nearest even".  So 42.5 goes to 42, but 43.5 goes to 44.

I notice our NUMERIC rounding code does not do that ... perhaps it

Also, the numeric round() function is just plain broken:

regression=# select round(42.5::numeric);
ERROR:  Function 'numeric_round(numeric, int4)' does not exist
        Unable to identify a function that satisfies the given argument types
        You may need to add explicit typecasts
regression=# select round(42.5::numeric,0);
(1 row)

Looks like a silly oversight in the pg_proc entry for round(numeric).

			regards, tom lane

In response to


pgsql-docs by date

Next:From: Ryan KirkpatrickDate: 2000-12-19 01:59:34
Subject: Re: 7.1 features list
Previous:From: He Weiping(Laser Henry)Date: 2000-12-19 00:48:30
Subject: some errors and/or bugs?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group