Re: BUG #8317: ROUND(double*1/2) != ROUND(1/2*double)

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: remi(dot)cura(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8317: ROUND(double*1/2) != ROUND(1/2*double)
Date: 2013-07-22 13:06:06
Message-ID: 20130722130606.GD13444@alap2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2013-07-22 09:44:58 +0000, remi(dot)cura(at)gmail(dot)com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 8317
> Logged by: Rémi
> Email address: remi(dot)cura(at)gmail(dot)com
> PostgreSQL version: 9.2.4
> Operating system: Ubuntu 12.0.4 32 bits hosted by a VirtualBox
> Description:
>
> Hello;
> I ran into a strange behaviour.
> Initially it showed in a group by, but is also happens in regular select :
>
>
> example :
> SELECT 2*ROUND(1/2*3.2)
> --> gives 0
> SELECT 2*ROUND(3.2*1/2)
> --> gives 3
>
>
> Obviously both should return the same thing, preferably 3.
> It looks like a bug to me, or at least a non desirable behaviour.

Hm. Doesn't really look like a bug to me. The first parses as:
ROUND((1/2) * 3.2), the second as ROUND((3.2 * 1) / 2). So the different
result makes sense to me.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Stehule 2013-07-22 13:08:50 Re: BUG #8317: ROUND(double*1/2) != ROUND(1/2*double)
Previous Message g.bakalarski 2013-07-22 12:54:13 BUG #8318: memory leak during CREATE TEMPORARY TABLE