Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJordan Dearan
621 Pointswhy does Multiplication take precedence over addition/subtraction
why does Multiplication take precedence over addition/subtraction
2 Answers
Andrés Leal
9,563 PointsIt's known as the standard hierarchy of operations It says that first goes the Parenthesis -> Exponents and roots -> Multiplication and Division -> Addition and Subtraction So first you multiply or divide and then you make the addition or subtraction Hope it helps :D
Gavin Maxwell
3,521 PointsIt's worth mentioning this has nothing to do with Swift, iOS, or computers in general. Most kids are taught this mathematical rule in grade school. The reason for it is like any other rule where ambiguity is possible - to remove the ambiguity. Some calculators and programming languages utilise Reverse Polish Notation (RPN), or postfix notation - this avoids any ambiguity, without the need for parentheses, by pushing operands and then the operator onto a stack. There's lots of background on all of this if you do some searching.