ceil() function behavior in postgresql While using the ceil() in postgresql, I found some strange behavior of it, Please see SQL :

Select  
     *,
     ceil( (550*0.5)/100 ),
     ceil( (58*5)/100 ),
FROM
   XYZ


If I focus on the output of ceil functions it is strange :


ceil( (550*0.5)/100 ) Returning 3 ( Which converts 2.75 to 3 )  
ceil((58*5)/100 ) Returning 2 ( Which converts 2.9 to 2 )


Why 2nd statement returning 2 if it is closed to the greater integer 3 ?
Description
  The PostgreSQL ceil function returns the smallest integer value that is greater than or equal to a number.


And according Postgres Docs:


  Except where noted, any given form of a function returns the same data type as its argument.


As you can see it works properly, in fact, if you use integers the returned value is one integer (58 * 5) / 100) returns 2 but if you forces it to decimal (58.0 * 5.0) / 100.0 then it returns 2.9.




select 
     (550 * 0.5) / 100 as C1,
     ceil((550 * 0.5) / 100) as CEIL_C1,
     (58 * 5) / 100 as C2,
     ceil((58 * 5) / 100) as CEIL_C2,
     (58.0 * 5.0) / 100.0 as C3,
     ceil((58.0 * 5.0) / 100.0) as CEIL_C3
;



                c1 | ceil_c1 | c2 | ceil_c2 |                 c3 | ceil_c3
-----------------: | ------: | -: | :------ | -----------------: | ------:
2.7500000000000000 |       3 |  2 | 2       | 2.9000000000000000 |       3



dbfiddle here