[Rd] Bug Report: Incorrect precedence between / and %/% in R 4.4.1
Tim Taylor
t|m@t@y|or @end|ng |rom h|ddene|eph@nt@@co@uk
Fri Jan 31 14:48:17 CET 2025
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 using 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 using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list