Re: Rounding strategy - Mailing list pgsql-docs

From Tom Lane
Subject Re: Rounding strategy
Date
Msg-id 1100756.1619113820@sss.pgh.pa.us
Whole thread Raw
In response to Re: Rounding strategy  (Laurenz Albe <laurenz.albe@cybertec.at>)
Responses Re: Rounding strategy  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-docs
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Mon, 2021-04-19 at 08:00 +0000, PG Doc comments form wrote:
>> The 'round' mathematical function documentation doesn't specify its rounding
>> strategy. If this would be documented then users can rely on its rounding
>> behavior. For double precision the rounding probably depends on your
>> platform. For numeric the function seems to round to nearest with ties going
>> away from zero (sometimes referred to as "round half up). 6.5 -> 7.0 and
>> -6.5 -> -7.0.

> Here is a proposed patch.

LGTM, although I think we can be a bit more specific about the float
case.  I suggest

        ... by rounding away from 0.  For <type>double precision</type>,
        the tie-breaking behavior is platform dependent, but
        <quote>round to nearest even</quote> is the most common rule.

            regards, tom lane



pgsql-docs by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Rounding strategy
Next
From: Laurenz Albe
Date:
Subject: Re: Rounding strategy