From: | Christoph Moench-Tegeder <cmt(at)burggraben(dot)net> |
---|---|
To: | Daria Shanina <vilensipkdm(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: rounding_up |
Date: | 2025-04-14 13:47:13 |
Message-ID: | Z_0R4WEfarJUHNYn@sciurus.exwg.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
## Daria Shanina (vilensipkdm(at)gmail(dot)com):
> I noticed, when we parse and validate values (in particular, the int type),
> we use the *rint* method, but unfortunately it does not work according to
> the round rules.
First question would be "which round rule?" as (of course) there're
multiple to chose from.
Second, the rules in use are consistent with the documentation of
round(double precision)
: Rounds to nearest integer. For numeric, ties are broken by rounding
: away from zero. For double precision, the tie-breaking behavior is
: platform dependent, but “round to nearest even” is the most common rule.
https://www.postgresql.org/docs/current/functions-math.html
and I think it makes sense to have round() and implicit rounding
behave the same.
Third, rint() works the way you set it to with fesetround() (see
man page). And that works on the nearest Linux and FreeBSD I
could grab :)
Regards,
Christoph
--
Spare Space.
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2025-04-14 14:03:28 | Re: pgsql: Add function to get memory context stats for processes |
Previous Message | Tender Wang | 2025-04-14 13:34:16 | Typos in the comment for the estimate_multivariate_ndistinct() |