+ 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 Respuestas
+ 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