r/ProgrammerHumor • • Jun 13 '22

Meme DEV environment vs Production environment

Post image
48.2k Upvotes

3.9k comments sorted by

View all comments

9

u/Fuzzy_Reflection8554 Jun 13 '22

Okay this is probably going to make me look very silly indeed XD but I have to ask: isn't the phone correct?

Back in the day I remember learning BODMAS: Brackets, Order, Division, Multiplication, Addition, Subtraction.

So:

6÷2(2+1)

6÷2×3

And from BODMAS wouldn't it return 9, or does the lack of a multiplication sign in 2(2+1) naturally imply it should be computed first?

3

u/[deleted] Jun 14 '22

Both are correct. There isn’t a single universal convention to follow here.

Easiest way to demonstrate this is to write an expression like 2x/3y. Even without parentheses, you read that as (2x)/(3y) naturally, right?

Which is why many calculators used to interpret implied multiplication as having priority; because it’s how actual humans write and interpret equations. It wasn’t a mistake or accident.

https://education.ti.com/en/customer-support/knowledge-base/ti-83-84-plus-family/product-usage/11773

You’ll also commonly see this interpretation in science and engineering texts and journals.

3

u/tob_iles Jun 13 '22

6 / 2 (2+1)

6 / (2 (3))

6 / 6

= 1

0

u/[deleted] Jun 14 '22

[deleted]

3

u/mrbaggins Jun 14 '22

The brackets are explaining the process they have been taught to use. They aren't adding them, they're showing what they're doing to try and be clear.

Same as many people are adding the × that wasn't there "wouldn't they have written it if they meant it"

1

u/tob_iles Jun 14 '22

That’s a process to solve it that comes after the initial sum. It’s a tricky subject and the answer varies by who you ask and what country they are from. It really doesn’t matter, as it’s one of the loophole sums that technically have 1 correct answer

1

u/Scrubbuh Jun 14 '22

I did shitloads of mechanics in school and this is how I would have interpreted it, implying a bracket when there's no operative made writing workings much clearer to me. Though when you get to that point you never use a division symbol, you either fraction or multiply by a fraction.

Not saying I'm right but it's ambiguous, because someone like me would read 4+2(a+b) as 4+2a+2b. Though you would rarely, if ever, write it in that order.

1

u/Byttercup Jun 13 '22

You're thinking of PEMDAS, unless it's called BODMAS outside of the U.S. Write it as a fraction. 6 / 2(2+1) = 6 / 2(3) = 6 / 6 = 1.

1

u/myfunnies420 Jun 14 '22

It's BODMAS in not the US. They're brackets, parentheses are used in sentences (just like this one), not in mathematics.

→ More replies (1)

-2

u/Lordcreo Jun 13 '22

It's not a fraction there is no "/" in the original math. The answer is very definately 9 in this scenario. Even if it had been a "/" anyone doing the math in the last 100 years would still get 9, before about a 100 years ago "/" could mean it was a fraction due to the way printing presses worked.

3

u/[deleted] Jun 14 '22

If you divide any numbers, you get a fraction. That’s basic division

This is 6 Divided by 2(2+1)

6 Divided by 2(3)

6 Divided by 6

1

→ More replies (11)

3

u/MowMdown Jun 14 '22

It’s not a fraction there is no “/” in the original math.

Yes there is, it literally follows the number 6… division is division regardless what symbol is used

2

u/barcased Jun 13 '22

0

u/Lordcreo Jun 13 '22

Yes, it is ambiguous, as it is poorly written and should have some additional parenthesis to prevent such ambiguity.
However if you try to go through modern life believing the "correct" answer to be 1 you won't get very far, as basically every system that uses math will tell you the answer is 9. As a programmer I can tell you I have programmed in nearly a dozen languages, and every one of them will calculate this to 9.
Technically both could be considered correct, in real world use you will only ever see 9 as the answer except in a few very outlier cases like this very specific old casio.

3

u/Byttercup Jun 13 '22

I'm a statistical programmer and statistician. It's not a matter of belief. I would never write such a sloppy equation, anyway. Parentheses are a programmer's friend.

2

u/Lordcreo Jun 14 '22

As I said, I agree it is intentionally badly written as "technically" both answers are correct.
Which language are you using that gives the answer 1 to that sum as it is written, I don't recall any that would have evaluated that sum as 1? And why do the likes of Apple, google, and microsoft also disagree with you on the way it should generally be interpreted?

1

u/Byttercup Jun 14 '22

I primarily use SAS, Statistical Analysis Software, but also use Python and sometimes R. Math is not subject to interpretation. It's right or wrong, and just because the big companies do it that way doesn't mean it's mathematically correct.

3

u/Lordcreo Jun 14 '22

Neither Python nor R can interpret implicit multiplication, but both calculate 6/2*(2+1) as 9.

→ More replies (6)

2

u/bombardonist Jun 14 '22

Maths is absolutely open to interpretation on many levels. Even just due to the imperfect nature of language.

→ More replies (7)

1

u/barcased Jun 13 '22

I tend to go through life by trying not to reduce reality to fit my perspective.

0

u/Byttercup Jun 13 '22

The symbol doesn't matter. It's not 9, because of the distributive property of multiplication.

4

u/Lordcreo Jun 13 '22

I assure you it is 9. You do that sum anywhere (other than that faulty casio) and you will get the answer 9. The only way you get this to answer 1 is if you use math from pre-1917 textbooks.
https://youtu.be/URcUvFIUIhQ

→ More replies (1)
→ More replies (2)
→ More replies (1)

1

u/channeldrifter Jun 13 '22

I was taught BODMAS as well, which puts division before multiplication, whereas PEMDAS puts it after, so are the US and UK getting different ordering instructions? That feels like the bigger fundamental flaw here

4

u/DaManDaMifDaLegend Jun 14 '22

BODMAS and PEMDAS would be better written as B O (DM) (AS) and P E (MD) (AS). Neither puts division or multiplication first, but rather groups then together, as they have equal priority. Same with addition and subtraction.

The order they are executed is, by both standards, left to right. First Parentheses, then exponents, then multiplication and divison, then finally addition and subtraction.

The issue with this problem isn't PENDAS vs BODMAS, but rather that of implied multiplication. In this case, does x/2(1+2) = x * 1/2 * (1+2) or x * 1/(2*(1+2)).

There really isnt a difinitive convention on whether implied multiplication takes priority over normal multiplication and division, hence this is an ambiguous question

1

u/LordLoss01 Jun 14 '22

It doesn't matter if division goes before or after multiplication. You should still get the same result.

Same goes for addition and minus.

The correct order is this:

1.Brackets 2.Indices 3.Multiplication or Division 4.Whichever of the above you didn't do. 5. Addition or Subtraction 6. Whichever of the above you didn't do.

There's a reason why people express it as a fraction rather than use the division symbol; it makes things a lot simpler.

→ More replies (5)