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

31st Mar 2020, 8:12 PM
Ravi Mishra
Ravi Mishra - avatar
3 Respostas
+ 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
3rd Apr 2020, 8:29 AM
Payal Sharma
Payal Sharma - avatar
+ 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.
1st Apr 2020, 3:23 AM
Aditya Agrawal
Aditya Agrawal - avatar
0
bepis
5th Apr 2020, 3:38 PM
BlueJ
BlueJ - avatar