Re: any plans to support more rounding methods in sql? - Mailing list pgsql-general

From Peter Geoghegan
Subject Re: any plans to support more rounding methods in sql?
Date
Msg-id CAEYLb_URu=woX6NoVEVQ7xmjUQTSw6cYX-V=j8DWK5J1vQBg6Q@mail.gmail.com
Whole thread Raw
In response to Re: any plans to support more rounding methods in sql?  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general
On 25 January 2012 05:41, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Hello
>
> 2012/1/25 raf <raf@raf.org>:
>> hi,
>>
>> i just needed to round some numbers down to 4 decimal places but a quick search
>> indicated that postgresql doesn't support all of the rounding methods so i had
>> to write this dreadful function:

Are you talking about always rounding down to the lower
smallest-possible-increment, rather than following standard rules for
rounding? That isn't such an esoteric use case - I believe that
financial regulations in some jurisdictions require just that when
calculating interest, for example.

If you require exactly 4 digits of precision, it's possible to use this syntax:

NUMERIC(precision, scale)

That isn't going to affect the rounding behaviour though.

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services

pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: any plans to support more rounding methods in sql?
Next
From: Chris Angelico
Date:
Subject: Re: Best way to create unique primary keys across schemas?