Re: Re: SQL error: function round(double precision, integer) does not exist

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vladimir Nicolici <vladnc(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Re: SQL error: function round(double precision, integer) does not exist
Date: 2017-05-25 18:22:37
Message-ID: 16285.1495736557@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Vladimir Nicolici <vladnc(at)gmail(dot)com> writes:
> I do that, but its extremely annoying.

Well, if it rises to the level of extreme annoyance for you, there
is a simple solution:

create function round(float8, int) returns numeric as
'select round($1::numeric, $2)' language sql;

> Furthermore, since the single parameter version accepts double precision numbers, the imprecise representation excuse seems questionable at best.

The single-parameter version always rounds to integer, which avoids the
problem of not being able to represent decimal fractions exactly.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Vladimir Nicolici 2017-05-25 18:23:33 Re: Re: SQL error: function round(double precision, integer) does not exist
Previous Message David G. Johnston 2017-05-25 17:56:09 Re: Re: SQL error: function round(double precision, integer) does not exist