Dear R Development Team, I have encountered an unexpected behavior in R 4.4.1 regarding the precedence of / and %/%. Steps to reproduce: print(2 * 10 / 2 %/% 50) Expected result: Since *, / and %/% have the same precedence, evaluation should be left-to-right: (2 * 10) / 2 %/% 50 # Expected: 0 Actual result: [1] Inf Workaround: Adding explicit parentheses fixes the issue: print(((2 * 10) / 2) %/% 50) # Returns 0 (as expected) This suggests that %/% is evaluated before /, contradicting the expected left-associativity. Could you please confirm if this is a known issue ? Best regards, LIONEL FOTIE Data Scientist - GroupM Germany GmbH - Office: +49211 81991563 V?lklinger Stra?e 33 | 40221 D?sseldorf | Germany - Join us: Karriere <https://karriere.groupm.de/de> | www.groupm.de<https://www.groupm.de/> Follow us: Facebook<https://www.facebook.com/GroupMGermany> | X<https://twitter.com/GroupMGermany> | Xing<https://www.xing.com/companies/groupmgermanygmbh> | LinkedIn<https://www.linkedin.com/company/groupm-germany/> | Instagram<https://www.instagram.com/groupm_germany/?hl=de>
Bug Report: Incorrect precedence between / and %/% in R 4.4.1
2 messages · Lionel Fotie, Tim Taylor
The higher precedence of %/% is documented in ?Syntax. Did something in particular make you think that it had the same precedence? Tim
On 31 Jan 2025, at 13:37, Lionel Fotie via R-devel <r-devel at r-project.org> wrote: ?Dear R Development Team, I have encountered an unexpected behavior in R 4.4.1 regarding the precedence of / and %/%. Steps to reproduce: print(2 * 10 / 2 %/% 50) Expected result: Since *, / and %/% have the same precedence, evaluation should be left-to-right: (2 * 10) / 2 %/% 50 # Expected: 0 Actual result: [1] Inf Workaround: Adding explicit parentheses fixes the issue: print(((2 * 10) / 2) %/% 50) # Returns 0 (as expected) This suggests that %/% is evaluated before /, contradicting the expected left-associativity. Could you please confirm if this is a known issue ? Best regards, LIONEL FOTIE Data Scientist - GroupM Germany GmbH - Office: +49211 81991563 V?lklinger Stra?e 33 | 40221 D?sseldorf | Germany - Join us: Karriere <https://karriere.groupm.de/de> | www.groupm.de<https://www.groupm.de/> Follow us: Facebook<https://www.facebook.com/GroupMGermany> | X<https://twitter.com/GroupMGermany> | Xing<https://www.xing.com/companies/groupmgermanygmbh> | LinkedIn<https://www.linkedin.com/company/groupm-germany/> | Instagram<https://www.instagram.com/groupm_germany/?hl=de> [[alternative HTML version deleted]]
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel