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

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Rémi Cura <remi(dot)cura(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #8317: ROUND(double*1/2) != ROUND(1/2*double)
Date: 2013-07-30 21:17:36
Message-ID: 1375219056.72045.YahooMailNeo@web162903.mail.bf1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Rémi Cura <remi(dot)cura(at)gmail(dot)com> wrote:

> 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)

The correct link is:

http://www.postgresql.org/docs/9.2/static/sql-syntax-lexical.html#SQL-PRECEDENCE-TABLE

And it shows multiplication, division, and modulo as having equal
precedence, with left-to-right associativity.

> So anyway the query is parsed as ( 1/ (2*3.2)) and ( 3.2*1) / 2 ),

No, it is ((1 / 2) * 3.2) and ((3.2 * 1) / 2).

Those evaluate to (0 * 3.2) and (3.2 / 2), respectively.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2013-07-30 21:25:21 Re: BUG #8345: PostGre SQL database is crashing
Previous Message Warwick Chapman 2013-07-30 20:39:11 Re: PostgreSQL and OpenVZ