Re: any plans to support more rounding methods in sql?

From: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: any plans to support more rounding methods in sql?
Date: 2012-01-25 06:04:17
Message-ID: CAEYLb_URu=woX6NoVEVQ7xmjUQTSw6cYX-V=j8DWK5J1vQBg6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 25 January 2012 05:41, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> Hello
>
> 2012/1/25 raf <raf(at)raf(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Angelico 2012-01-25 06:18:30 Re: Best way to create unique primary keys across schemas?
Previous Message Pavel Stehule 2012-01-25 05:41:00 Re: any plans to support more rounding methods in sql?