Search Postgresql Archives

Re: Unexpected result using floor() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



100 is an integer
 power(10,2) is a double precision.

Try this one:

SELECT floor(4.725 * 100::double precision + 0.5);




On Mon, Mar 14, 2016 at 10:11 AM, Frank Millman <frank@xxxxxxxxxxxx> wrote:
Hi all
 
I am running PostgreSQL 9.4.4 on Fedora 22.
 
SELECT floor(4.725 * 100 + 0.5) returns 473, which is what I expected.
 
SELECT floor(4.725 * power(10, 2) + 0.5) returns 472, which I find surprising.
 
Please can someone explain the anomaly.
 
Thanks
 
Frank Millman
 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux