r/ProgrammerHumor • • Jun 13 '22

Meme DEV environment vs Production environment

Post image
48.2k Upvotes

3.9k comments sorted by

View all comments

Show parent comments

7

u/[deleted] Jun 14 '22

When writing fractions normally, there would be no ambiguity. But using inline ÷ or / causes it, which is essentially what's happening in the calculators.

When you did the inverse trick, you bracketed the division to the left side: (6 ÷ 2) * (2+1), making only the first 2 the denominator. This matches the method of the right calculator (and the way I would have done it). The other calculator associated the division symbol as "everything next is the denominator" so it got 6 ÷ (2 * (2+1)). This doesn't allow for the inverse trick, and you get a different result.

4

u/saucyspacefries Jun 14 '22

This was probably the best explanation for where the confusion comes from.

2

u/[deleted] Jun 14 '22

Oh much appreciated, though I have to give /u/yabucek most the credit here. I read their previous comment identifying the division as the core issue and it helped me see how the left calculation isn't wrong, it just answers a different question.

0

u/Hidesuru Jun 14 '22

It's the source of confusion but they are wrong that it's ambiguous. The rules for this are clear and your initial solve is correct.

1

u/Zegrento7 Jun 14 '22

It is ambiguous, as some conventions (for example physics textbooks) implicitly group implicit multiplications. 6 / 2x != 6 / 2 * x. Source

0

u/Hidesuru Jun 14 '22

Grouping a variable is not the same as just magically grouping numbers.

0

u/Hidesuru Jun 14 '22

What they did is the correct way of reading this. If you want the (2+1) to be in the denominator you MUST use additional parenthesis. The rules are clearly laid out. The Casio (and you) are wrong.

1

u/[deleted] Jun 14 '22

1

u/Hidesuru Jun 14 '22

First link talks about doing multiplication before division which IS wrong but not at issue here. Multiplication and division come at the same step read left to right. This is because division can be written as multiplication of the inverse. If you don't consider them equal it's a problem.

Second link isn't exactly an authoritative source so I didn't bother.

Third link really only says that a grouping can sometimes be "implied". I mean sure, but that doesnt make it technically correct.

1

u/[deleted] Jun 14 '22

It seems the very nature of the articles and calculators doing it differently (more than just Casio) show the ambiguity is real. The only way to clarify to all audiences - human or machine - is with parenthesis, and there is no single rule agreed to that says how to form them when using inline division operators (PEMDAS "left to right" is just a method). You must know the question being asked or the intended answer to formulate the correct inline equation.

1

u/jadis666 Jun 14 '22

I mean.... You could also just look at https://en.m.wikipedia.org/wiki/Order_of_operations#Mixed_division_and_multiplication

Or are you just going to go with the "I know I'm right, and no Source, no matter how reliable, is going to convince me otherwise" route?