agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Vladimir Nicolici <vladnc@gmail.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Re: SQL error: function round(double precision, integer) does not exist
Date: Thu, 25 May 2017 14:22:37 -0400
Message-ID: <16285.1495736557@sss.pgh.pa.us> (raw)
In-Reply-To: <DB6P195MB0056E207F3CE474BE77AA368F7FF0@DB6P195MB0056.EURP195.PROD.OUTLOOK.COM>
References: <DB6P195MB00566D30994F8BD7B04B5605F7FF0@DB6P195MB0056.EURP195.PROD.OUTLOOK.COM>
	<16203.1495734888@sss.pgh.pa.us>
	<DB6P195MB0056E207F3CE474BE77AA368F7FF0@DB6P195MB0056.EURP195.PROD.OUTLOOK.COM>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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 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


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (16+ messages)  latest in thread

Message-ID: <16285.1495736557@sss.pgh.pa.us>
Permalink:  ../16285.1495736557@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16285.1495736557@sss.pgh.pa.us

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-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, vladnc@gmail.com
  Subject: Re: Re: SQL error: function round(double precision, integer) does not exist
  In-Reply-To: <16285.1495736557@sss.pgh.pa.us>

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

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