Rounding Problems?

From: elbriga <gabrielortizlour(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Rounding Problems?
Date: 2016-11-29 12:22:40
Message-ID: 1480422160303-5932388.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I have this pl function:
CREATE OR REPLACE FUNCTION ceilDecimal(num float) RETURNS float AS
$BODY$
BEGIN
RETURN CEIL(num * 100) / 100;
END
$BODY$
LANGUAGE 'plpgsql';

It is supposed to do a "decimail ceil" for 2 decimal places.
But when I do "SELECT ceilDecimal(0.07)"
It will return
ceildecimal
-------------
0.08

For other numbers the result is as expected:
SELECT ceilDecimal(0.17);
ceildecimal
-------------
0.17

WHY? rsrsr

Thanks in advance!

--
View this message in context: http://postgresql.nabble.com/Rounding-Problems-tp5932388.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Saulo Tadeu 2016-11-29 12:25:50 Postrgres-XL and Postgres-BDR
Previous Message Stuart Bishop 2016-11-29 12:06:51 Re: Storing files: 2.3TBytes, 17M file count