
I hate signatures!
That only works if + and − associate to tthe right; they don't They associate to the left; that expression therefore evaluates to (+)3.Piet Souris wrote:. . . 3  3 + 3 would have been 3. . . .
Campbell Ritchie wrote:Assuming that the juxtaposition of the 2 and the (2 + 2) means multiplication, the * and / operators have the same precedence and the same associativity (left).
Campbell Ritchie wrote:If juxtaposition has a higher precedence than division, then the answer is 1. But we aren't working out 2x but 2•4. Does that precedence still apply?
And remind me, doesn't the square have a higher precedence than the doubing in the top of that expression.
Thank you. I think we shall have to be conventional and agree to disagree. If the editor decides, well that depends on whether they have printed riddles like the one about saving fuel on an aeroplane with a cargo of birds by rattling their cages and making all the birds fly.Stephan van Hulst wrote:. . . Any time you find this kind of question in newspapers or in social media, you will see that the expression is intentionally formatted to make it ambiguous. The correct answer depends entirely on what the editor in question decides is the correct answer. . . .
Campbell Ritchie wrote:
That only works if + and − associate to tthe right; they don't They associate to the left; that expression therefore evaluates to (+)3.Piet Souris wrote:. . . 3  3 + 3 would have been 3. . . .
I hate signatures!
Piet Souris wrote:When I was in primary school (19621968) we had the sentence: Meneer Van Dam Wacht Op Antwoord, meaning powers, multiplication, division, square roots, addition, subtraction. It didn't mention parentheses, but the answer would have been 1. Like 3  3 + 3 would have been 3. But then came these computers, spoiling it all...
There are only two hard things in computer science: cache invalidation, naming things, and offbyone errors
Campbell Ritchie wrote:That will only evaluate to 0 if
1: + has a precedence higher than − or, 2: + and − associate to the right Does Meneer Van Dam Wacht Op Bier mean that all the precedences are different? (...)
I hate signatures!
fred rosenberger wrote:(...)
but your phrase really confuses me. You did square roots AFTER multiplication? what about cube roots, or fractional roots? and roots are again the same thing as powers, so why do they come so late? if you has a power of 3/2, do you do it as a power or as a root? PLEASE don't tell me you'd cube it, then multiply/divide, and THEN do the root. that would break my brain.
I hate signatures!
I was taught the same: long lines imply () too. But that doesn't only apply to √. I know the HTML escape √ for √ but I don't think there is an overscore symbol.Mike Simmons wrote:. . . implicit parenthesis based on the length of the horizontal line at the top. . . .
It's easy... Try dividing 3 toys between two siblings and you'll realize that the answer is correct !!!Mike Simmons wrote:Try justifying that to any nonprogrammer...
That division has two possible solutions: 0 and 3salvin francis wrote:. . . Try dividing 3 toys between two siblings . . .
All of the following truths are shameless lies. But what about this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn KlassenKoop
https://coderanch.com/wiki/718759/books/BuildingWorldBackyardPaulWheaton
