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

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

[BUGS] BUG #14695: Documentation is not accurate

От
yarex@pobox.sk
Дата:
The following bug has been logged on the website:

Bug reference:      14695
Logged by:          Jaroslav Sivy
Email address:      yarex@pobox.sk
PostgreSQL version: 9.6.3
Operating system:   n/a
Description:

url: https://www.postgresql.org/docs/8.1/static/functions-math.html

CEIL and FLOOR example is not accurate.

ceil(dp or numeric) 
smallest integer not less than argument: ceil(-42.8) = -42

..... well, minus 42 is not smallest integer from -42.8, because -42 is
bigger number :-).

..... so correct number should be -43 in case of negative numbers
(positive are fine)

Same applies to FLOOR from negative numbers, where its opposite.


--
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] BUG #14695: Documentation is not accurate

От
Tom Lane
Дата:
yarex@pobox.sk writes:
> url: https://www.postgresql.org/docs/8.1/static/functions-math.html

> CEIL and FLOOR example is not accurate.

> ceil(dp or numeric) 
> smallest integer not less than argument: ceil(-42.8) = -42

That example is just fine: it describes both the actual behavior
of the software, and the desired behavior.  ceil() is effectively
"round towards plus infinity".  You seem to be expecting "round
away from zero", but that's not how it's defined.  For comparison,
the Linux man page for the C ceil() function says
      For example, ceil(0.5) is 1.0, and ceil(-0.5) is 0.0.
        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] BUG #14695: Documentation is not accurate

От
"David G. Johnston"
Дата:
On Thursday, June 8, 2017, <yarex@pobox.sk> wrote:


url: https://www.postgresql.org/docs/8.1/static/functions-math.html

CEIL and FLOOR example is not accurate.

ceil(dp or numeric)
smallest integer not less than argument: ceil(-42.8) = -42

..... well, minus 42 is not smallest integer from -42.8, because -42 is
bigger number :-).
..... so correct number should be -43 in case of negative numbers
(positive are fine)


The key phase is "integer not less than argument" and -43 < -42 and so cannot be a valid answer.
 
Like Tom said:

The integers from -41 to positive infinity are the set of potential answers per the noted phrase.  You pick the smallest of them which is -41.

David J.