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

From: Rémi Cura <remi(dot)cura(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(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 14:14:22
Message-ID: CAJvUf_uuVTrQb2R-WwJJ-2B-mphV9TLViWWvkQ7phfRWDUXH6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi, thanks for your quick answers.

To close this non-bug :
According to the doc (
http://www.postgresql.org/docs/9.2/static/sql-syntax-lexical.html#SQL-SYNTAX-OPERATORS
)
, multiplication has precedence on division. (I supposed it implicitely)
So anyway the query is parsed as ( 1/ (2*3.2)) and ( 3.2*1) / 2 ), and so
the behaviour is consistant.

Cheers ,

Rémi

2013/7/22 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>

> 2013/7/22 <remi(dot)cura(at)gmail(dot)com>:
> > 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
> >
> >
>
> Hello
>
> It is not a bug - a reason for this behave is using a integer div in first
> case
>
> ( 1 / 2 ) * 3.2 ... 1/2 .. integer div, because left operand is int
> and right operand is int
> (3.2 * 1) / 2 ... 3.2 / 2 .. using numeric div, left operand is
> numeric and right operand is int
>
> Regards
>
> Pavel Stehule
>
>
>
> > Obviously both should return the same thing, preferably 3.
> > It looks like a bug to me, or at least a non desirable behaviour.
> >
> >
> > Cheers,
> > Rémi
> >
> >
> >
> > --
> > Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-bugs
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2013-07-22 15:29:22 Re: 9.3beta2 unrecognized node type in join alias vars when retrieving view definition
Previous Message Feike Steenbergen 2013-07-22 13:10:32 Re: 9.3beta2 unrecognized node type in join alias vars when retrieving view definition