I'm working on modernizing Rosetta Code's infrastructure. Starting with communications. Please accept this time-limited open invite to RC's Slack.. --Michael Mol (talk) 20:59, 30 May 2020 (UTC)

Talk:Operator precedence

From Rosetta Code

maybe a little more specific?[edit]

What does "associate from left to right" mean?

When I look at

((a + b) + c)

or

(a + (b + c))

I could implement either of them by associating from left to right. In the first case, I would be doing bottom-up association, in the second case I would be doing top-down association. --Rdm 18:20, 24 September 2012 (UTC)

From here, given the expression without parenthesis of a + b + c then if '+' is left associative it should be evaluated as (a + b) + c, which I think is what was meant by "associate from left to right". You can add brackets to make the evaluation order explicit, the associativity is used when you don't. --Paddy3118 20:12, 24 September 2012 (UTC)
In the specific case of + as applied to integers (either of unlimited precision or in the finite 2s-complement groups as usually implemented by modern hardware) the associativity doesn't matter too much as the operation is also properly commutative. Where it does matter is with operators like division, exponentiation or list-prepending. (It also matters with addition of floating point numbers, but for more subtle reasons.) –Donal Fellows 07:55, 27 September 2012 (UTC)