Обсуждение: Re: [BUGS] Re: [BUGS] BUG #14695: Documentation is not accurate

Поиск
Список
Период
Сортировка

Re: [BUGS] Re: [BUGS] BUG #14695: Documentation is not accurate

От
Tom Lane
Дата:
Jaroslav Sivy <yarex@pobox.sk> writes:
> The problem is in "largest integer not greater than argument" and "smallest integer not less than argument"
> As you can see Largest integer from -42.8 is not -43, but infact its 42, because in negative numbers -42 > -43

Well, it still looks correct to me.  FWIW, you're not the first to be
confused by this.  In currently-supported releases we've rephrased it as

ceil(dp or numeric)    nearest integer greater than or equal to argument

floor(dp or numeric)    nearest integer less than or equal to argument

But 8.1 is six years out of support and its docs aren't going to be
updated any more.
        regards, tom lane


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Re: [BUGS] Re: [BUGS] BUG #14695: Documentation is not accurate

От
Arthur Nascimento
Дата:

On Fri, Jun 9, 2017 at 12:59 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Well, it still looks correct to me. FWIW, you're not the first to be
> confused by this. In currently-supported releases we've rephrased it as

> ceil(dp or numeric) nearest integer greater than or equal to argument

> floor(dp or numeric) nearest integer less than or equal to argument

While I do agree that the current docs on ceil() and floor() are good, I also think that the description of round() is really not on par with them, since I've seen people stumble on that more than once. So maybe this is a good opportunity to improve it.

[3] describes round() as "nearest integer", but according to [1], that could be understood as any one of 6 deterministic plus 2 non-deterministic methods.

In reality, the behavior is actually "half away from zero" for numeric and "half to even" for floating point (on some machines). While this is well documented somewhere else (last paragraph of 8.1.2 in [2]), there is no clear link between [3] and [2] for people who who search for round().

So I think the docs on round() could be improved in one of two ways:
- copy the rounding description from [2] to [3] so people know what they are getting when calling round(); or,
--

Arthur Nascimento - tureba