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

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: kamiya33hirokazu(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Explanation of the ROUND function with NUMERIC as an argument
Date: 2022-12-03 13:34:56
Message-ID: 3da3dcc06220f80537dc1fb2c32cb76c91f87b93.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Sat, 2022-12-03 at 08:54 +0000, PG Doc comments form wrote:
> Explanation of the manual's ROUND function
> round ( numeric ) → numeric
> round ( double precision ) → 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.
> round(42.4) → 42
>
> Operation of the ROUND function
> postgres=# SELECT round(CAST(42.5 AS numeric));
>  round
> -------
>     43
> (1 row)
>
> 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.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2022-12-03 14:19:40 Re: Explanation of the ROUND function with NUMERIC as an argument
Previous Message PG Doc comments form 2022-12-03 08:54:32 Explanation of the ROUND function with NUMERIC as an argument