Re: Explanation of the ROUND function with NUMERIC as an argument - Mailing list pgsql-docs

From Laurenz Albe
Subject Re: Explanation of the ROUND function with NUMERIC as an argument
Date
Msg-id 3da3dcc06220f80537dc1fb2c32cb76c91f87b93.camel@cybertec.at
Whole thread Raw
In response to Explanation of the ROUND function with NUMERIC as an argument  (PG Doc comments form <noreply@postgresql.org>)
Responses Re: Explanation of the ROUND function with NUMERIC as an argument
List 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 by date:

Previous
From: PG Doc comments form
Date:
Subject: Explanation of the ROUND function with NUMERIC as an argument
Next
From: Tom Lane
Date:
Subject: Re: Explanation of the ROUND function with NUMERIC as an argument