pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14695: Documentation is not accurate
5+ messages / 4 participants
[nested] [flat]
* BUG #14695: Documentation is not accurate
@ 2017-06-09 06:57 yarex@pobox.sk
2017-06-09 14:01 ` Re: BUG #14695: Documentation is not accurate Tom Lane <tgl@sss.pgh.pa.us>
2017-06-09 15:02 ` Re: BUG #14695: Documentation is not accurate David G. Johnston <david.g.johnston@gmail.com>
2017-06-09 15:59 ` Re: Re: [BUGS] BUG #14695: Documentation is not accurate Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 3 replies; 5+ messages in thread
From: yarex@pobox.sk @ 2017-06-09 06:57 UTC (permalink / raw)
To: pgsql-bugs
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #14695: Documentation is not accurate
2017-06-09 06:57 BUG #14695: Documentation is not accurate yarex@pobox.sk
@ 2017-06-09 14:01 ` Tom Lane <tgl@sss.pgh.pa.us>
2 siblings, 0 replies; 5+ messages in thread
From: Tom Lane @ 2017-06-09 14:01 UTC (permalink / raw)
To: yarex@pobox.sk; +Cc: pgsql-bugs
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #14695: Documentation is not accurate
2017-06-09 06:57 BUG #14695: Documentation is not accurate yarex@pobox.sk
@ 2017-06-09 15:02 ` David G. Johnston <david.g.johnston@gmail.com>
2 siblings, 0 replies; 5+ messages in thread
From: David G. Johnston @ 2017-06-09 15:02 UTC (permalink / raw)
To: yarex@pobox.sk <yarex@pobox.sk>; +Cc: pgsql-bugs
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.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Re: [BUGS] BUG #14695: Documentation is not accurate
2017-06-09 06:57 BUG #14695: Documentation is not accurate yarex@pobox.sk
@ 2017-06-09 15:59 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-06-09 16:54 ` Re: Re: [BUGS] BUG #14695: Documentation is not accurate Arthur Nascimento <tureba@gmail.com>
2 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2017-06-09 15:59 UTC (permalink / raw)
To: Jaroslav Sivy <yarex@pobox.sk>; +Cc: pgsql-bugs
=?utf-8?q?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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Re: [BUGS] BUG #14695: Documentation is not accurate
2017-06-09 06:57 BUG #14695: Documentation is not accurate yarex@pobox.sk
2017-06-09 15:59 ` Re: Re: [BUGS] BUG #14695: Documentation is not accurate Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-06-09 16:54 ` Arthur Nascimento <tureba@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Nascimento @ 2017-06-09 16:54 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Jaroslav Sivy <yarex@pobox.sk>; +Cc: pgsql-bugs
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,
- put a link somewhere in [3] pointing towards [2] so that people can find
the related pages in one glance.
[1] https://en.wikipedia.org/wiki/Rounding#Comparison_of_rounding_modes
[2]
https://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL
[3] https://www.postgresql.org/docs/current/static/functions-math.html
--
Arthur Nascimento - tureba
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2017-06-09 16:54 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-06-09 06:57 BUG #14695: Documentation is not accurate yarex@pobox.sk
2017-06-09 14:01 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-06-09 15:02 ` David G. Johnston <david.g.johnston@gmail.com>
2017-06-09 15:59 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-06-09 16:54 ` Arthur Nascimento <tureba@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox