Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics (retired) Operators Operator Precedence

Mohammad Faizal Mulla
Mohammad Faizal Mulla
355 Points

Hi Amit, on 3.34 in your video you state that x, / and + have the same priority. I thought + is lower in precedence?

Is there an error in the video, because Amit states that + also has same precedence as x, /?

Michael Vilabrera
Michael Vilabrera
Courses Plus Student 11,252 Points

maybe % was intended? You are correct- + & - are lower in precedence. PEMDAS always

J.D. Sandifer
J.D. Sandifer
18,813 Points

Does PEMDAS stand for Parentheses, Exponent, Multiplication, Division, Addition, and Subtraction (in that order)?

I never learned that, but it looks like it would have been helpful.

Reece Pena
Reece Pena
925 Points

PEMDAS does stand for Parentheses, Exponent, Multiplication, Division, Addition, and Subtraction. However some of them have the same level of precedence. So it should be PE(MD)(AS) because Multiplication and Division have the same precedence level, whilst Addition and Subtraction have the same level as well, however Addition and Subtraction or lower than Multiplication and Division. If you have Multiplication and Division in the same equation, then the operator thats closest to the left has supremacy.