Re: Unexpected result using floor() function

From: Chris Mair <chris(at)1006(dot)org>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Pujol Mathieu <mathieu(dot)pujol(at)realfusio(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Unexpected result using floor() function
Date: 2016-03-14 20:45:02
Message-ID: 0330e2fc5115dab378d6282dc283b088@smtp.hushmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

maybe this is a late reply, but also note that 4.725 alone already cannot be
represented in floating point exactly (and this has nothing to do with Postgres).

Just sum it up 100 times to "see" the round off error becoming visible:

chris=# select sum(4.725::double precision) from generate_series(1,100);
sum
------------------
472.500000000001
(1 row)

vs.

chris=# select sum(4.725::numeric) from generate_series(1,100);
sum
---------
472.500
(1 row)

Bye,
Chris.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message drum.lucas@gmail.com 2016-03-14 21:13:15 Unique UUID value - PostgreSQL 9.2
Previous Message Peter Geoghegan 2016-03-14 20:20:07 Re: ON CONFLICT DO NOTHING RETURNING