Re: Rounding Problems?

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "'elbriga *EXTERN*'" <gabrielortizlour(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Rounding Problems?
Date: 2016-11-29 13:58:27
Message-ID: A737B7A37273E048B164557ADEF4A58B5399E5B4@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

elbriga wrote:
> Thanks for the detailed answer!
>
> Changing the function sinature seams to have solved the problem:
> CREATE OR REPLACE FUNCTION ceilDecimal(num numeric) RETURNS float AS
> $BODY$
> BEGIN
> RETURN CEIL(num * 100) / 100;
> END
> $BODY$
> LANGUAGE 'plpgsql';
>
>
> SELECT ceilDecimal(0.07);
> ceildecimal
> -------------
> 0.07

Yes, because "numeric" stores the exact number, so it will be
exactly 0.07 after conversion.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-11-29 15:27:24 Re: Storing files: 2.3TBytes, 17M file count
Previous Message elbriga 2016-11-29 13:43:24 Re: Rounding Problems?