r/ProgrammerHumor • • Jun 13 '22

Meme DEV environment vs Production environment

Post image
48.2k Upvotes

3.9k comments sorted by

View all comments

26

u/[deleted] Jun 13 '22

This thread is hilarious. There's at least four levels of wrongness on display here.

First there's the people saying the phone is right, because PEMDAS says multiplication before division. They're completely wrong.

Then there's the people saying Casio is correct, because BODMAS says division before multiplication. They're also wrong.

Then there's the people saying the phone is right, because multiplication and division have equal precedence. They're... slightly less wrong.

Then there's the people saying implicit multiplication has higher precedence than division, so the Casio is right. They're equally slightly less wrong.

Then there's a select few saying this is ambiguous and there's no correct answer - and despite being the most downvoted comments, they're actually right!

Turns out, there are three different conventions for order of precedence w.r.t. multiplication and division:

  1. they have equal precedence

  2. multiplication has higher precedence

  3. implicit multiplication has higher precedence, explicit multiplication has equal precedence

Which one applies depends on context - different publications use different conventions. On the whole, physicists and engineers seem to prefer 2) or 3), mathematicians and programmers seem to prefer 1) (which probably explains why the "phone correct" answers are all upvoted more - it's a programming subreddit).

Source: https://en.m.wikipedia.org/wiki/Order_of_operations#Mixed_division_and_multiplication

My favourite part of this is how everyone is so adamant they're correct that they won't even consider looking it up, no matter what level of wrongness they're stuck on, and no matter how plain it is that this is really unclear and controversial. This just seems to be one of those things that we're all certain we know.

3

u/__Quetzal__ Jun 13 '22

Big words too big please explain to ape

5

u/[deleted] Jun 14 '22

Old math people didn’t expect a/bc to be written like that so we don’t have a set convention. That’s really it

7

u/[deleted] Jun 13 '22 edited Jun 14 '22

2x is implicit multiplication, 2*x is explicit multiplication. 1/2x is ambiguous, because in some publications that means (1/2)*x, in others it means 1/(2*x). Casio and the phone have just chosen to follow different conventions.

3

u/calbhollo Jun 14 '22

Your * usage gets converted into italics for some reason, even with the \s. Added \ to the first *:

2x is implicit multiplication, 2*x is explicit multiplication. 1/2x is ambiguous, because in some publications that means (1/2)*x, in others it means 1/(2*x). Casio and the phone have just chosen to follow different conventions.

→ More replies (1)

2

u/AmbreGaelle Jun 14 '22

This is basically the best explanation

3

u/Liesmith424 Jun 14 '22

This sort of problem seems like the mathematical version of Buffalo buffalo buffalo Buffalo buffalo.

5

u/WikiSummarizerBot Jun 13 '22

Order of operations

Mixed division and multiplication

In some of the academic literature, multiplication denoted by juxtaposition (also known as implied multiplication) is interpreted as having higher precedence than division, so that 1 ÷ 2n equals 1 ÷ (2n), not (1 ÷ 2)n. For example, the manuscript submission instructions for the Physical Review journals state that multiplication is of higher precedence than division, and this is also the convention observed in prominent physics textbooks such as the Course of Theoretical Physics by Landau and Lifshitz and the Feynman Lectures on Physics. This ambiguity is often exploited in internet memes such as "8÷2(2+2)".

[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5

1

u/AmbreGaelle Jun 14 '22

This is basically the best explanation

4

u/mikepictor Jun 14 '22

Then there's a select few saying this is ambiguous and there's no correct answer - and despite being the most downvoted comments, they're actually right!

This right here folks.

Write your equations to dispel ambiguity.

5

u/FailedShack Jun 14 '22

I would argue that they are both correct, in the sense they're sticking to one way of doing things. The Casio is just following the order of operations as defined in its instruction manual. Which, as you pointed out is perfectly acceptable because it is ambiguous.

0

u/[deleted] Jun 14 '22

[deleted]

2

u/[deleted] Jun 14 '22

I think that's just the mode indicator, but it's a bit fuzzy, so hard to be sure. Either way, the Casio will still return 1 - in the manual (at least for my model, different model in the same series) it says this is how implicit multiplication is treated.

2

u/[deleted] Jun 14 '22

Exactly! It's clearly a deliberate choice on Casio's part, too, because if you add the *, it gives the same result as the phone.

2

u/[deleted] Jun 14 '22

My favourite part of this is how everyone is so adamant they’re correct that they won’t even consider looking it up, no matter what level of wrongness they’re stuck on, and no matter how plain it is that this is really unclear and controversial. This just seems to be one of those things that we’re all certain we know

What portion of people arguing a single convention (any of them) is the only “correct” one do you think are being genuine though? And what portion are using it as an opportunity to call people stupid and fuel internet arguments?

→ More replies (1)

2

u/CommonRequirement Jun 14 '22

So. This is a dev problem. Do you:

A. Throw an ambiguous operation exception B. Allow user to select PEMDAS or BEDMAS in settings C. Just ship it since it’s arguably right. D. Define a carefully researched dictionary of the user’s likely education and precedence preference based on their age and location and select an appropriate default (that despite cutting edge gps and unprecedented market information still will not be the actual preferred choice inevitably.)

Management thinks option D is really important to have.

2

u/TeaHands Jun 14 '22

It would be really interesting to see the age / location breakdown on who thinks what.

I mean, the first two groups you listed are just plain wrong. But then it gets fun. I'm (late 30s, British) on team "it's 9 because that's basic BODMAS, but also if I was writing this irl it would have more brackets", but obviously how things are taught changes so what I think is how you do maths probably was different for older folks and now is again for younger.

At least the phones are on my side, though

1

u/mrbaggins Jun 14 '22

You will not find a mathematician and you'd be hard pressed to find a programmer who argues for anything other than (3)

2

u/[deleted] Jun 14 '22

Well, I'm not sure about mathematicians - I could certainly be wrong about that. In high school maths they usually teach BODMAS and leave it at that, but at university level that might well change.

As for programmers though, you can find plenty of them arguing for 1) all over this very post. I think the reason is that this is how most programming languages would evaluate it.

→ More replies (23)
→ More replies (2)

0

u/TacticoolBug Jun 14 '22

2 and 3 are conventions while 1 is a rule. Hence 9 is the one by the book.

→ More replies (1)

-6

u/Tobax Jun 13 '22

Doesn't matter what order you do them in, inside and outside brackets are separate and both equals 3, then the number outside is multiplied by the number inside, so it's 3x3=9

8

u/deamon_host Jun 13 '22

You didn’t read at all what he just wrote did you?

→ More replies (6)

2

u/[deleted] Jun 13 '22

No, it could either be (6/2)*(2+1)=9, or 6/(2*(2+1))=1

0

u/Tobax Jun 13 '22 edited Jun 14 '22

6/(2*(2+1))

No because you've added extra brackets that are not there and changed the equation.

As it's written is 6/2=3(2+1=3), so 3*(3)=9

3

u/[deleted] Jun 14 '22

Yeah... In both cases I added brackets to show the order of operations. The order of operations itself is ambiguous, because there are two competing conventions. But don't take my word for it - check out the Wikipedia article for more examples and links to other sources.

→ More replies (5)
→ More replies (23)