Re: [SQL] Re: SQL error: function round(double precision, integer) does not exist - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] Re: SQL error: function round(double precision, integer) does not exist
Date
Msg-id 16285.1495736557@sss.pgh.pa.us
Whole thread Raw
In response to Re: [SQL] Re: SQL error: function round(double precision, integer)does not exist  (Vladimir Nicolici <vladnc@gmail.com>)
Responses Re: [SQL] Re: SQL error: function round(double precision, integer)does not exist  (Vladimir Nicolici <vladnc@gmail.com>)
List pgsql-sql
Vladimir Nicolici <vladnc@gmail.com> writes:
> I do that, but it’s 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
seemsquestionable 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



pgsql-sql by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: [SQL] Re: SQL error: function round(double precision, integer)does not exist
Next
From: Vladimir Nicolici
Date:
Subject: Re: [SQL] Re: SQL error: function round(double precision, integer)does not exist