+ 3

# What are the values of (-3)%2, 3%(-2), (-3)%(-2)?

2 Answers

+ 5

Apple says "The sign of b is ignored for negative values of b. This means that a % b and a % -b always give the same result."
So, the sign of a is important. if a is positive then the remainder is positive.
if a is negative then the remainder is negative. if remainder is zero then signs are not important.

+ 2

(-3)%2 = -1
3%(-2) = 1
(-3)%(-2) = -1