Re: [GENERAL] Rounding Problems?

2016-11-29 Thread elbriga
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




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


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


[GENERAL] Rounding Problems?

2016-11-29 Thread elbriga
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.


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