Difference between modulo and remainder operators? | SoloLearn: Learn to code for FREE!

+3

Difference between modulo and remainder operators?

I know both are about same. But Swift strictly uses Remainder operator rather than modulo. Are they exactly same or different?

3/31/2020 8:12:14 PM

®k👨🏻‍💻Mî$πR@

3 Answers

New Answer

+3

Modulus is always the same sign as the divisor But  remainder is the same sign as the quotient. And may be that's why swift uses remainder operator

+1

There is a difference between modulus and remainder. For example: -21 mod 4 is 3 because -21 + 4 x 6 is 3. But -21 divided by 4 gives -5 with a remainder of -1. For positive values, there is no difference. This is from stack overflow btw.

0

bepis