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
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
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.
GET THE FREE APP
Learn Playing. Play Learning
Send us a message