Re: Explanation of the ROUND function with NUMERIC as an argument

From: hirokazu kamiya <kamiya33hirokazu(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Explanation of the ROUND function with NUMERIC as an argument
Date: 2022-12-03 14:46:00
Message-ID: CAHCSegyV5uJdr9cFHHJ55CLpQ3+h-=pOMjNu5zbSgaUbbyByJQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Thank you for your answer.
I am convinced.
Thank you for replying to my question in poor English.

2022年12月3日(土) 23:19 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> writes:
> > On Sat, 2022-12-03 at 08:54 +0000, PG Doc comments form wrote:
> >> I am thinking that the value of the ROUND function with NUMERIC as an
> >> argument is rounded off, not rounded away from zero.
>
> > It is rounded away from zero, since 43 is farther away from 0 than 42.5.
> > This may be a language problem.
>
> Perhaps, since I don't see anything wrong with that text either.
> (Of course, it's moderately likely that I wrote that text,
> or at least copy-edited it at some point ;-). Don't remember.)
>
> The point is that for 42.5, or anything-point-5, the basic
> "round to nearest integer" rule is insufficient because 42 and
> 43 are equally near. We need a tie-breaking rule, and for numeric
> that rule has historically been to round to the larger absolute
> value (or "away from zero", as the text puts it to avoid two-dollar
> terminology). Sadly, that is not what IEEE has established as
> best practice for floating-point rounding, so round(float8)
> acts differently.
>
> regards, tom lane
>

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Kirk Wolak 2022-12-04 03:02:36 Re: nextval parameter is not clear
Previous Message Tom Lane 2022-12-03 14:19:40 Re: Explanation of the ROUND function with NUMERIC as an argument