Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of evaluation of the modulo operator #6225

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Order of evaluation of the modulo operator #6225

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2017-02-22 09:52:32 +0100
From: Frédéric Jolliton <<frederic.jolliton+monetdb>>
To: SQL devs <>
Version: 11.25.5 (Dec2016-SP1)

Last updated: 2017-07-17 16:07:33 +0200

Comment 25053

Date: 2017-02-22 09:52:32 +0100
From: Frédéric Jolliton <<frederic.jolliton+monetdb>>

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36
Build Identifier:

The modulo operator should have the same order of evaluation as the division.

  • 1010/3 == 33, since it is evaluated as (1010)/3.
  • 1010%3 == 10, which is wrong because it was evaluated as 10(10%3)

Reproducible: Always

Steps to Reproduce:

Evaluate 10 * 10 % 3

Actual Results:

10

Expected Results:

1

Comment 25084

Date: 2017-03-02 17:48:39 +0100
From: MonetDB Mercurial Repository <>

Changeset 469a57574048 made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=469a57574048

Changeset description:

Fixed operator precedence of % to be equal to * and /.
This fixes bug #6225.

Comment 25085

Date: 2017-03-02 17:51:31 +0100
From: @sjoerdmullender

The SQL standard doesn't mention the % operator for modulo/remainder, so I guess we can do whatever we want. But I agree it's a good idea to follow the lead of languages such as C where % / and * all have equal priority.

The SQL standard only mentions MOD as in
::=
<MOD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant