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

Поиск
Список
Период
Сортировка
От Laurenz Albe
Тема Re: Explanation of the ROUND function with NUMERIC as an argument
Дата
Msg-id 3da3dcc06220f80537dc1fb2c32cb76c91f87b93.camel@cybertec.at
обсуждение исходный текст
Ответ на Explanation of the ROUND function with NUMERIC as an argument  (PG Doc comments form <noreply@postgresql.org>)
Ответы Re: Explanation of the ROUND function with NUMERIC as an argument  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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



В списке pgsql-docs по дате отправления:

Предыдущее
От: PG Doc comments form
Дата:
Сообщение: Explanation of the ROUND function with NUMERIC as an argument
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Explanation of the ROUND function with NUMERIC as an argument