Comment on I dunno
Feathercrown@lemmy.world 1 month agoPE(MD)(AS)
Now just remember to account for those parentheses first…
Comment on I dunno
Feathercrown@lemmy.world 1 month agoPE(MD)(AS)
Now just remember to account for those parentheses first…
SmartmanApps@programming.dev 3 weeks ago
Those Brackets don’t matter. I don’t know why people insist it does
Feathercrown@lemmy.world 3 weeks ago
They do, it’s grouping those operations to say that they have the same precedence. Without them it implies you always do addition before subtraction, for example.
SmartmanApps@programming.dev 3 weeks ago
They don’t. It’s irrelevant that they have the same priority. MD and DM are both correct, and AS and SA are both correct.
And there’s absolutely nothing wrong with doing that, for example. You still always get the correct answer
Feathercrown@lemmy.world 3 weeks ago
Uh, no. I don’t think you’ve thought this through, or you’re just using (AS) without realizing it. Conversations around operator precedence can cause real differences in how expressions are evaluated and if you think everyone else is just being pedantic or is confused then you might not underatand it yourself.
Take for example the expression 3-2+1.
With (AS), 3-2+1 = (3-2)+1 = 1+1 = 2. This is what you would expect, since we do generally agree to evaluate addition and subtraction with the same precedence left-to-right.
With SA, the evaluation is the same, and you get the same answer. No issue there for this expression.
But with AS, 3-2+1 = 3-(2+1) = 3-3 = 0. So evaluating A with higher precedence rather than equal precedence yields a different answer.