8 / 2 (2 + 2) =

I did this in half a dozen programming languages from python to c++ and every single one of them says 16.

Keep in mind I had to “correct” the formula to 8/2*(2+2).

This is why, when I’m programming I tend to use parens if there is any way it’s not 100% obvious, even sometimes when it’s not necessary.

I agree with those above that mention the slant division sign rather than the horizontal line. Using the horizontal notation makes it more clear. But if you want to get 1 either way, toss parens around the 2*(2+2)
 
I did this in half a dozen programming languages from python to c++ and every single one of them says 16.

Keep in mind I had to “correct” the formula to 8/2*(2+2).

This is why, when I’m programming I tend to use parens if there is any way it’s not 100% obvious, even sometimes when it’s not necessary.

I agree with those above that mention the slant division sign rather than the horizontal line. Using the horizontal notation makes it more clear. But if you want to get 1 either way, toss parens around the 2*(2+2)
This is not a math (maths for the UK contingent) failure. It is a transcription problem. It is written ambiguously. How you interpret the equation leads to your chosen answer.

I remember years ago when Saturday Night Live was funny. They had a skit where the outgoing senior nuclear engineer was retiring. His last instruction to the control room was: (paraphrasing) You can never give a reactor too much water.

Half of the people interpreted it as: don't give the reactor too much water.
The other half interpreted it as: The reactor can never have too much water.

The failure is in the problem statement, not the result.

When in doubt, use parenthesis. You can never have too many parenthesis.
 
How does division fit into the order of operations? Does it have a higher, lower, or equivalent precedence than multiplication?
I'm not saying this is empirically correct. But, along with every student in my district, I was taught that each operation has a separate order of importance:
Parenthesis,
Exponents,
Multiplication. . . so it is above division,
Division . . . so it is below multiplication,
Addition,
Subtraction.
So, using the method I was taught, the answer is one.
 
I'm not saying this is empirically correct. But, along with every student in my district, I was taught that each operation has a separate order of importance:
Parenthesis,
Exponents,
Multiplication. . . so it is above division,
Division . . . so it is below multiplication,
Addition,
Subtraction.
So, using the method I was taught, the answer is one.

That's a common missconception, but the correct convention is that multiplication and division have equal precedence and are evaluated from the left. Addition and subtraction also have equal precedence and are evaluated from the left.

The multiplication before divison idea seems to come from teachers teaching that PEMDAS mnemonic which many people interpret to mean multiplication before division. That's just wrong. Ask any engineer, math major, scientist, or computer programmer.

See https://brainbrooder.com/lesson/57/...to remember,, division, addition, subtraction. for a good explanation.

Quoting from that website:

An easy way to remember the operator precedence is to remember the word pemdas, which is an acronym for: parentheses, exponents, multiplication, division, addition, subtraction.

This acronym is a bit dangerous however, as it seems to suggest that multiplication has precedence over division, and that addition has precedence over subtraction, which is not the case. These operations are performed from left to right.
 
I'm not saying this is empirically correct. But, along with every student in my district, I was taught that each operation has a separate order of importance:

Then the teachers did you you and all the other students in your district a significant disservice by teaching you incorrectly.
 
From another website:

For example: If we take PEMDAS (Parenthesis, Exponents, Multiplication, Division, Addition, Subtraction); those who following this blindly will always perform Multiplication before Division and Addition before Subtraction. And this can produce the wrong answer.

The truth is that the mnemonic should be PE( MD)(AS)LTR. This is because Multiplication and Division should be performed at the same time and Addition and Subtraction should be performed at the same time. And both should be calculated Left To Right.
 
Last edited:
From another website:

...following this blindly will always perform Multiplication before Division and Addition before Subtraction. And this can produce the wrong answer.
So, I asked AI for an example. Got this confused answer. In the overview, "1" is incorrect. In the explanation, "1" is correct, but the multiplication and division operations are mislabeled. Gofigr..


AI Overview
Learn more

An example where PEMDAS would give a wrong answer if multiplication was done before division is the expression "10 / 2 * 5" - if you multiply 2 and 5 first, you get 10, then divide 10 by 10, resulting in 1, which is incorrect; the correct way is to divide 10 by 2 first (getting 5), then multiply by 5, giving the answer 25.

Explanation:
  • Incorrect calculation (multiplying before dividing): (10 / 2) * 5 = (5) * 5 = 25
  • Correct calculation (dividing before multiplying): 10 / (2 * 5) = 10 / 10 = 1
 
I'm not saying this is empirically correct. But, along with every student in my district, I was taught that each operation has a separate order of importance:
Parenthesis,
Exponents,
Multiplication. . . so it is above division,
Division . . . so it is below multiplication,
Addition,
Subtraction.
So, using the method I was taught, the answer is one.
As others have mentioned, this is incorrect, and they have provided an explanation.

The only people who have been to the moon used "American" measurement.
Please consider losing the parochialism. As mentioned before, the computers were programmed to use metric units. However, the astronauts were pilots trained to use units such as feet-per-minute, so, for flight instruments, a conversion was applied so the astronauts could apply their existing training and reflexes to the flight.

Then the teachers did you you and all the other students in your district a significant disservice by teaching you incorrectly.
Is a more polite was of saying this:
Ask for a refund on your school tax.


And I literally just completed high school.
Your learning is just beginning, as you should see from this thread. What you were taught on this subject seems to be in error. Ask questions when you get an unexpected answer from someone.
 
Equations are left to right with PEMDAS applied. So:
Parenthesis 8/2(4)
MD (Multiplication/Division - Left to right) 4(4)
Result 16

Mathematics is not open to interpretation. Writing a mathematic equation is a recipe for confusion and resulting mis-interpretation.
Yes... but in this case, it's the written word that causes the confusion. "where's an English major when you need one?" (was that Garrison Keeler who said that?)

memorizing the acronym leaves out a lot of the intended meaning...the words between the words are lost.

....math is hard. words are hard too....
 
I thought it might be useful to discuss this whole topic in a bit more detail to explain the "why" about how the convention is that multiplication and division have equal precedence. Feel free to skip this and move on to something more exciting. I've been a math geek at least as early as when my 7th grade math teacher, Mrs. Sweeny, taught algebra to me in 1979.

It's well known that multiplication and division are inverse operators and are really two sides of the same coin. Dividing by 10 is equivalent to multiplying by 0.1. Multiplying by 1.25 is the same as dividing by 0.8, etc. 1/2 = 0.5, 3/4 = 0.75 etc.


So, for example: 2/2 = 2*0.5 = 1

Since multiplication and division are so closely related, mathematicians over the centuries have determined that the best convention is to treat the two operators as equivallent in precedence.

Take, for example 2 / 2 / 2

The convention is to evaluate from left to right:

( 2 / 2 ) / 2 = 1 / 2 = 0.5

If the convention had been defined to evaluate right to left it would be:

2 / ( 2 / 2) = 2 / 1 = 2
But that's not the agreed upon convention. It's left to right.

Now since dividing by 2 is the same as multplying by 0.5, the above could alternatively be written as

2 / 2 * 0.5 or 2 * 0.5 * 0.5 or 2 * 0.5 / 2

Using the left to right convention with multiplication having equal precedence, all of these evaluate to 0.5

If multiplication is given precedence over division or the evaluation direction is different, then different answers are found.

2 / 2 / 2 = 0.5 (correct according to convention when evaluated left to right)

2 / 2 / 2 = 2 (when evaluated right to left)

2 / 2 * 0.5 = 2 (when multiplication is given precedence)

2 * 0.5 * 0.5 = 0.5 (same answer evaluated either direction)

2 * 0.5 / 2 = 0.5 (same answer regardless of order or precedence)

So, there are different answers possible with basically the same calculation, and that leads to confusion and ambiguity. In order to deal with this, people have developed a set of syntax rules for the language of math that are generally agreed upon. A different set of rules could have been developed, but that's not what was done. What has been agreed upon generally is that for written equations (and most but not all computer languages), infix notation is used primarily, with multiplication and division having equivalent precedence and evaluated left to right. Addition and subtraction also have the equivalent precedence (lower than multiplication and division) and are also evaluated left to right. In the written form, multiplication is understood to be implied when writing dissimilar types adjacent to each other as in 2x, (x - 3)(x + 4), 2(2 + 2), etc. Most programming languages don't parse that correctly requiring: 2*x, (x-3)*(x+4), 2*(2+2).

Note, that there are other conventions used in some places.

The programming language Lisp uses prefix notation. In Lisp, 8 / 2 (2+2) would be written as: (* (/ 8 2)(+ 2 2))

In Reverse Polish Notation (RPN), a postfix way of calculating, 8 / 2(2 +2) would be calculated as

8 2 / 2 2 + *

But those are somewhat special cases. Most programming languages (python for example) write it this way:

8 / 2 * ( 2 + 2 )
Python evaluates the above as 16,

Excel: =8/2*(2+2)
Excel also evaluates that as 16
 
Last edited:

I had an HP-11C all through college. Was a wonderful calculator with RPN (as God intended) which was a constant companion in all of my Electrical Engineering classes. Used to enjoy (Yes, I'm petty) it in my Computer Science minor classes when a CS major would ask to borrow my calculator. "Sure thing" sez I. It was funny to watch them puzzling over the keyboard. Where's the equals key? Maybe this ENTER key is the same as the EQUALS KEY? Hmmmm, Let's see 2 * 2 ENTER? No, that can't be right? How the heck does this thing work? They'd usually hand it back to me with a sheepish, "thanks", and then borrow someone else's "normal" calculator.

RPN is a much more efficient way of using a calculator, isn't it?
 
If the convention had been defined to evaluate right to left it would be:
If the Persians, who invented algebra close to the modern form, had continued their work, I wondered if this may have been the convention.


He merely put it into context of other systems.
 
I did this in half a dozen programming languages from python to c++ and every single one of them says 16.

Keep in mind I had to “correct” the formula to 8/2*(2+2).

This is why, when I’m programming I tend to use parens if there is any way it’s not 100% obvious, even sometimes when it’s not necessary.

I agree with those above that mention the slant division sign rather than the horizontal line. Using the horizontal notation makes it more clear. But if you want to get 1 either way, toss parens around the 2*(2+2)
Would you agree then that if a horizontal line was used instead of a slant line, the solution would be 1? I interpret the slant line to be equivalent to a horizontal line with everything past the slant under it, unless otherwise bracketed.
 
If the Persians, who invented algebra close to the modern form, had continued their work, I wondered if this may have been the convention.

Interesting thought. I just asked my Persian born wife how she learned things in Iran. When she was growing up there, she said that they evaluated left to right, but they used Farsi numerals instead of the Hindu-Arabic we use. But yeah, right to left could definitely have been an option. They certainly write/read right to left. Kinda makes my mind explode.
 
Would you agree then that if a horizontal line was used instead of a slant line, the solution would be 1? I interpret the slant line to be equivalent to a horizontal line with everything past the slant under it, unless otherwise bracketed.
If the line was long and the formula clearly fits under it, it would be 1
 
Would you agree then that if a horizontal line was used instead of a slant line, the solution would be 1? I interpret the slant line to be equivalent to a horizontal line with everything past the slant under it, unless otherwise bracketed.

If the equation were written as:


8
-------
2(2+2)

Then yes, the answer is 1. But that is not how the equation was written, and the interpretation of treating the slant as a horizontal divider separating everything to the right of it is, frankly, incorrect and not in line with generally the generally accepted conventions of math. Sorry, but it's just wrong.

Thought experiment for you: How would you interpret: 2x / (3 + x)(x-6)^2/ (3 + 6x^3) / 6 ?

That's straightforward to interpret using the conventional rules. It's not if one treats the / as a horizontal line.
 
Interesting thought. I just asked my Persian born wife how she learned things in Iran. When she was growing up there, she said that they evaluated left to right, but they used Farsi numerals instead of the Hindu-Arabic we use. But yeah, right to left could definitely have been an option. They certainly write/read right to left. Kinda makes my mind explode.
Thank you for adding some context. Yes, I was thinking about how they read and write when I wrote my comment. But the dominant cultures that expanded on algebra wrote from left-to-right so we get the order we do.
 
I had an HP-11C all through college. Was a wonderful calculator with RPN (as God intended) which was a constant companion in all of my Electrical Engineering classes. Used to enjoy (Yes, I'm petty) it in my Computer Science minor classes when a CS major would ask to borrow my calculator. "Sure thing" sez I. It was funny to watch them puzzling over the keyboard. Where's the equals key? Maybe this ENTER key is the same as the EQUALS KEY? Hmmmm, Let's see 2 * 2 ENTER? No, that can't be right? How the heck does this thing work? They'd usually hand it back to me with a sheepish, "thanks", and then borrow someone else's "normal" calculator.

RPN is a much more efficient way of using a calculator, isn't it?

I used a TI-58 through college, but then when I started my engineering career I bought an HP-15C. The keys on the TI went bad (which led me to buying the HP), but I'm retired now and still using the same HP. The HP-11, HP-12, and HP-15 calculators were basically a lifetime buy.
 
I interpret the slant line to be equivalent to a horizontal line with everything past the slant under it, unless otherwise bracketed.
Why not treat the multiplication symbol in the same fashion? They are related operators with the same precedence. Would you treat everything after the multiplication symbol as if they were grouped together?

Both multiplication and division only take 2 operands, so the interpretations that @Salty used work well.
 
Interesting thought. I just asked my Persian born wife how she learned things in Iran. When she was growing up there, she said that they evaluated left to right, but they used Farsi numerals instead of the Hindu-Arabic we use. But yeah, right to left could definitely have been an option. They certainly write/read right to left. Kinda makes my mind explode.

Oops, my wife just googled it. (she did leave Iran at age 10) According to Google, Persian calculations are, indeed, right to left in classic farsi.
 
I used a TI-58 through college, but then when I started my engineering career I bought an HP-15C. The keys on the TI went bad (which led me to buying the HP), but I'm retired now and still using the same HP. The HP-11, HP-12, and HP-15 calculators were basically a lifetime buy.
I'm not familiar with the TI 58...but my TI experience was that they all failed by entering more digits than pressed. One press of 9 would result in 99999999. Is that what happened to yours?

Yep, I still have my 11c, and it still works just fine (although the LCD is bleeding at the edge a bit).. Used it all through school, then for most of my career. I ended up with a 15c from my father-in-law, in pristine shape. I don't use it at work though. One of those stupid ideas where I think it's worth too much so it sits in a drawer!!??!! Yeah, now that I think about it maybe I'll bring it in after my winter break, and start using it again! Currently, I have an HP 35S I use at work. I like it because I work with a lot of mixed whole number and fractional dimensions and it has the A b/c button, so one fewer keystrokes to enter for example 12 27/32
 
I used a TI-58 through college, but then when I started my engineering career I bought an HP-15C. The keys on the TI went bad (which led me to buying the HP), but I'm retired now and still using the same HP. The HP-11, HP-12, and HP-15 calculators were basically a lifetime buy.
My experience, too. My TI-58 (59?) got the same failure that seemed to plague all Texas Instruments calculators: the debounce, or whatever, would fail and you’d get multiple keypresses each time.

Not only were the HP calculators a one-time buy, but they were pretty well engineered to maximize battery life. I remember buying one, not even one of their top models and I used it nearly every day for work. Over the next 20 or so years I might have replaced the batteries once.
 
Last edited:
yep, great battery life...and as I recall more precise calculations compared to cheaper models when carrying out a long line of significant digits
 
I'm not familiar with the TI 58...but my TI experience was that they all failed by entering more digits than pressed. One press of 9 would result in 99999999. Is that what happened to yours?

Yes, exactly. Also, I had an early one without continuous memory so it would lose programming whenever I shut it off, which was pretty inconvenient.

I remember considering an HP-41, but I liked that the HP-15 was small enough to fit into a pocket.
 
I bought my HP-15 in 1984 and I doubt I’ve replaced the batteries five times.
I was issued my HP-15C in 1984 at USMA. Freshman math included a module on RPN, with timed calculations on the HP. Standing at attention in front of your desk of course, sometimes with a belt buckle and shoe inspection.
 
Actually, it's a compile error so everyone is wrong. In procedural programming languages, there's no operand between the first occurring 2 and the left parenthesis.

Python code:
print(8 / 2 (2 + 2))

Results:
Python 3.13.0 (v3.13.0:60403a5409f, Oct 7 2024, 00:37:40) [Clang 15.0.0 (clang-1500.3.9.4)]
Type "help", "copyright", "credits" or "license" for more information.
[evaluate t.py]
x-wingide-python-shell://4604484320/2:2: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
Traceback (most recent call last):
File "/Users/blanche/Desktop/t.py", line 2, in <module>
print(8 / 2 (2 + 2))
builtins.TypeError: 'int' object is not callable
---------------
Java code:
public class t {
public static void main(String [] args) {
System.out.println(" " + 8 / 2 (2 + 2));
}
}

Results:
t.java:3: error: ')' or ',' expected
System.out.println(" " + 8 / 2 (2 + 2));
^
1 error
----------
C code:
#include <stdio.h>
int main() {
// Defining the variables
int result;

// Evaluating the equation 8 / 2 (2 + 2)
result = 8 / 2 (2 + 2); // This follows the order of operations correctly.

// Output the result
printf("Result of 8 / 2 * (2 + 2) = %d\n", result);
return 0;
}


Results:

t.cc:7:20: error: called object type 'int' is not a function or function pointer
7 | result = 8 / 2 (2 + 2); // This follows the order of operations correctly.
| ~ ^
1 error generated.



Shall I go on?
 
Last edited:
When they have been failed by the education system? Yes. It was directed at the school system, which charged a lot of money for the education it provided, not at her.

It's might be ok for people that haven't done any serious math in 20 years to struggle with this. A fresh high school graduate? Not that ok.
Same thing I told a long time ago to an ERAU student that was interning with us. He struggled solving 3x^2+5x=12.
Simple 2nd order polynomial ax^2 + bx + c = 0 or, 3x^2 + 5x - 12 = 0
for which the solution is the quadratic equation (I leave it to you to google it)

x1 = -5 + sqrt(disc) all over 6
x2 = -5 - sqrt(disc) all over 6

disc = 25 - (4 * 3 - (-12)) or 169 and sqrt(169) is 13

Fortunately, a (or 3) isn't zero. If it were, then I'd invoke the 11th Commandment - Thou Shalt Not Divide by Zero

x1 = (-5 + 13)/6 or 1.33...
x2 = (-5 - 13/6 or -3.0
 
I did this in half a dozen programming languages from python to c++ and every single one of them says 16.

Keep in mind I had to “correct” the formula to 8/2*(2+2).

This is why, when I’m programming I tend to use parens if there is any way it’s not 100% obvious, even sometimes when it’s not necessary.

I agree with those above that mention the slant division sign rather than the horizontal line. Using the horizontal notation makes it more clear. But if you want to get 1 either way, toss parens around the 2*(2+2)
But I didn't correct it, I took it exactly as offered, which is incorrect in every programming language.
 
I'm not saying this is empirically correct. But, along with every student in my district, I was taught that each operation has a separate order of importance:
Parenthesis,
Exponents,
Multiplication. . . so it is above division,
Division . . . so it is below multiplication,
Addition,
Subtraction.
So, using the method I was taught, the answer is one.
Interesting....I was never taught this mnemonic. I was just taught the correct order of precedence. Which, by the way, is entirely dependent on the programming language because not all procedural languages have the exact same set of operators.
 
Last edited:
I'm not saying this is empirically correct. But, along with every student in my district, I was taught that each operation has a separate order of importance:
Parenthesis,
Exponents,
Multiplication. . . so it is above division,
Division . . . so it is below multiplication,
Addition,
Subtraction.
So, using the method I was taught, the answer is one.
What do ya say @2-Bit Speed ....par for your neck of the woods as well?
 
If the equation were written as:


8
-------
2(2+2)

Then yes, the answer is 1. But that is not how the equation was written, and the interpretation of treating the slant as a horizontal divider separating everything to the right of it is, frankly, incorrect and not in line with generally the generally accepted conventions of math. Sorry, but it's just wrong.

Thought experiment for you: How would you interpret: 2x / (3 + x)(x-6)^2/ (3 + 6x^3) / 6 ?

That's straightforward to interpret using the conventional rules. It's not if one treats the / as a horizontal line.
In my own defense, the whole text character redefinition of the rules of precedence are relatively pretty f******g new.
 
What do ya say @2-Bit Speed ....par for your neck of the woods as well?
Both @2-Bit Speed and I learned the appropriate way of executing mathematical operations, but neither of us went to a public school so perhaps our experiences are not representative of the state of education in the local government facility at the time.
 
Back
Top