pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: kamiya33hirokazu@gmail.com
To: pgsql-docs@lists.postgresql.org
Subject: Re: Explanation of the ROUND function with NUMERIC as an argument
Date: Sat, 03 Dec 2022 14:34:56 +0100
Message-ID: <3da3dcc06220f80537dc1fb2c32cb76c91f87b93.camel@cybertec.at> (raw)
In-Reply-To: <167005767233.1899.2490889277144246641@wrigleys.postgresql.org>
References: <167005767233.1899.2490889277144246641@wrigleys.postgresql.org>

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





view thread (4+ messages)  latest in thread

Message-ID: <3da3dcc06220f80537dc1fb2c32cb76c91f87b93.camel@cybertec.at>
Permalink:  ../3da3dcc06220f80537dc1fb2c32cb76c91f87b93.camel@cybertec.at/
Also on:    postgresql.org/message-id/3da3dcc06220f80537dc1fb2c32cb76c91f87b93.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: laurenz.albe@cybertec.at, kamiya33hirokazu@gmail.com, pgsql-docs@lists.postgresql.org
  Subject: Re: Explanation of the ROUND function with NUMERIC as an argument
  In-Reply-To: <3da3dcc06220f80537dc1fb2c32cb76c91f87b93.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox