Unexpected result using floor() function

From: "Frank Millman" <frank(at)chagford(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Unexpected result using floor() function
Date: 2016-03-14 14:11:01
Message-ID: 2A49534B02644348A76354FC0A95A2AB@FrankLaptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pujol Mathieu 2016-03-14 14:21:12 Re: Unexpected result using floor() function
Previous Message Francisco Olarte 2016-03-14 10:31:47 Re: Suppress decimal point like digits in to_char?