Re: Allow round() function to accept float and double precision

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Sayyid Ali Sajjad Rizavi <sasrizavi@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2022-12-01T02:58:23Z
Lists: pgsql-hackers
On Thu, 1 Dec 2022 at 15:41, David G. Johnston
<david.g.johnston@gmail.com> wrote:
> I don't get the point of adding a function here (or at least one called round) - the type itself is inexact so, as you say, it is actually more of a type conversion with an ability to specify precision, which is exactly what you get today when you write 1.48373::numeric(20,3) - though it is a bit annoying having to specify an arbitrary precision.

An additional problem with that which you might have missed is that
you'd need to know what to specify in the precision part of the
typemod.  You might start getting errors one day if you don't select a
value large enough. That problem does not exist with round().  Having
to specify 131072 each time does not sound like a great solution, it's
not exactly a very memorable number.

David



Commits

  1. Doc: add example of round(v, s) with negative s.