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 trial

iOS Swift Basics (retired) Operators Operator Precedence

Fedor Andreev
Fedor Andreev
11,203 Points

Why is the % called the remainder? But in C++ it's called the modulo?

The remainder as a word in this context makes a lot more sense and I could instantly understand what it meant. But way back when I did C++ I couldn't understand what modulo meant until It was finally explained to me.

Why can't computer languages keep their definitions of operators consistent and easy to understand?

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

In most programming languages, the operator is called the Modulo, which returns the remainder. I'm sure, sometimes, if you are talking about the returned value (remainder) you would say remainder, but if you are talking about the actual operation in the code, I would say Modulo.

It kind of like if you were adding numbers. In the operation, you would say 3 plus 3, but if you were talking about the answer you would say the sum of 3 plus 3.

:)

both names are used interchangably, both are correct