[Rd] Bug Report: Incorrect precedence between / and %/% in R 4.4.1

2025-01-31 Thread Lionel Fotie via R-devel
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  | 
www.groupm.de
Follow us: Facebook | 
X | 
Xing | 
LinkedIn | 
Instagram


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Bug Report: Incorrect precedence between / and %/% in R 4.4.1

2025-01-31 Thread 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  
> 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  | 
> www.groupm.de
> Follow us: Facebook | 
> X | 
> Xing | 
> LinkedIn | 
> Instagram
> 
> 
>[[alternative HTML version deleted]]
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel