Advertisement

All Jokes aside, what is 6/2(1+2)?

Started by March 27, 2015 12:00 AM
115 comments, last by BaneTrapper 9 years, 9 months ago

The rules of order of operations dictates brackets, multiplication, division, addition and than subtraction .

Please acknowledge the corrections others have made—this is exactly what a programmer can absolutely not afford to misunderstand.
Multiplication, division, and modulus have the same priority and are executed in order of appearance.
Addition and subtraction follow have the same priority, again whichever comes first.

The question was not explicitly posed in the context of programming or any programming language. I don't know of many programming languages where 6/2(1+2) is a valid expression in the first place. tongue.png

Outside of that context many people are not taught that multiplication and division have equal precedence. They learn one of BEDMAS or PEMDAS or some other mismash of the two mnemonics, depending on where they grew up, and sticking to that precedence order is rather strictly enforced. At least, it was where I went to school (for me it was BEDMAS). So, for a lot of people, one of multiplication or division does in fact always have precedence. Given that different people are taught different precedence rules, I'd say the question as presented is too ambiguous to evaluate without more context. Of course, that appears to be the point.


Which convention yields an answer different than 9?

http://www.hsitechnologies.com/thesolution.php

Advertisement


http://www.hsitechnologies.com/thesolution.php

Haha, fair enough. That is quite a lengthy discussion. Although I have an engineering degree, I don't ever remember the "principle of implied multiplication", and have always learned the "computer science" way.


Given that different people are taught different precedence rules, I'd say the question as presented is too ambiguous to evaluate without more context. Of course, that appears to be the point.

This is a major issue though, wouldn't you say? If I am working at NASA, I'd hope everyone would be able to look at that equation as not being so ambiguous, because the difference between 1 and 9 is more than a major difference when it comes to rocket science, even in matters of programming (which wasn't the context of the original question). The rules of precedence are the rules, whether one was taught them or not.

Personally, I think a lot of people remember the PEMDAS thing, but don't remember the part that multiplication and division have no precedence over each other because division is just multiplication (multiplying by the reciprocal). Same goes for adding and subtracting (subtracting is just adding the negative). Even remembering PEMDAS, you still have the distributive property.

I think the only clarification I could have made was what L.Spiro said, but even then I would have typed (6/2)^(1+2).

P.S. The parenthesis should imply multiplication, but still some added?

They call me the Tutorial Doctor.

Personally, my answer would be to punch whoever wrote the equation in the face and tell them that this kind of stupid shit leads to engineering projects failing (possibly at the cost of human lives).

Write the damn equation clearly in the first place.

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

\[6/2(1 + 2) = (6/2)(1 + 2) = \frac{6}{2}(1 + 2) = 9 ~ ~ ~ ~ ~ ~ \text{and} ~ ~ ~ ~ ~ ~ 6/(2(1 + 2)) = \frac{6}{2(1 + 2)} = 1\]

The End. The precedence rules are simple; learn them, and then stop writing expressions in ASCII and use real typesetting software.

Also, on a related note, so-called "mixed numbers" are best left in your primary school math textbook and should not be used in the real world. Seriously, ask people what \(2 \frac{3}{4} \) is, some will correctly reply 3/2 and others will reply "2 and three quarters" (i.e. 2.75) because they were taught that fractions in this particular form should be read as a sum rather than a conventional multiplication, because it makes so much sense to have the same notation mean utterly different things to different people in the same mathematical context. Those same people will also agree that both addition and multiplication are commutative but will then happily contradict themselves by reading \(\frac{3}{4} 2 \) as 3/2 because it doesn't "look" like a mixed number anymore. Please. do the world a favour and just don't use them. /rantover

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Advertisement


Given that different people are taught different precedence rules, I'd say the question as presented is too ambiguous to evaluate without more context. Of course, that appears to be the point.

This is a major issue though, wouldn't you say? If I am working at NASA, I'd hope everyone would be able to look at that equation as not being so ambiguous, because the difference between 1 and 9 is more than a major difference when it comes to rocket science, even in matters of programming (which wasn't the context of the original question). The rules of precedence are the rules, whether one was taught them or not.

If you're working at NASA, you would make it clear either by adding the multiplication sign, parentheses, or as Bacterius points out, not using ASCII in the first place.

NASA engineers don't need to worry about the order of operations... it's converting metric measurements to imperial that they need to be wary about.

http://www.hsitechnologies.com/thesolution.php


Haha, fair enough. That is quite a lengthy discussion. Although I have an engineering degree, I don't ever remember the "principle of implied multiplication", and have always learned the "computer science" way.


I knew about the implied multiplication (I think Saxon Math uses it), but I've always learned PEMDAS ("Please Excuse My Dear Aunt Sally"), I think from 4th grade public school, and so assumed the Multiplication then Division ordering was set in stone. wacko.png

Also, on a related note, so-called "mixed numbers" are best left in your primary school math textbook and should not be used in the real world. Seriously, ask people what 2 3/4 is, some will correctly reply 3/2 and others will reply "2 and three quarters" (i.e. 2.75) because they were taught that fractions in this particular form should be read as a sum rather than a conventional multiplication, because it makes so much sense to have the same notation mean utterly different things to different people in the same mathematical context. Those same people will also agree that both addition and multiplication are commutative but will then happily contradict themselves by reading 3/4 2 as 3/2 because it doesn't "look" like a mixed number anymore. Please. do the world a favour and just don't use them. /rantover


That's a very good point. I'm one of those who would've got that "wrong". In this case, is it schools teaching things wrongly or is it two competing standards where one standard is superior to the other? I mean, some parts of the world use dd/mm/yyyy for dates, and some use mm/dd/yyyy, which leads to confusion. Clear one is superior to the other (dd/mm/yyyy), but neither is "wrong", just competing standards.

Personally, I use yyyy/mm/dd to avoid ambiguity and for proper filename sorting. I'll also now avoid mixed numbers, since I see the reasoning in your argument. (Thankfully, I'm already used to writing alot of things as decimals, preferring to multiply by 0.5 rather than divide by 2)

We were taught BODMAS at school, but also that implied multiplication had precedence over regular multiplication/division.

Okay, say the equation was ab(c+e) =

In middle school we saw the operators "a*b" or "a x b". Then we were taught later that "ab" is implied multiplication.

The issue I am seeing is where people distribute the "b" with the "c" and "e" and just leave the "a" all by itself. The "a" and the b together is one term. Since division is just multiplying by the reciprocal, nothing should change about how it is interpreted:

a(1/b)(c+e) = a/b(c+e)

They call me the Tutorial Doctor.

This topic is closed to new replies.

Advertisement