1 To find the remainder operation2 3To find the remainder operation (a%b) is the number of times B is just good enough to accommodate a, returning the extra portion (remainder). 4Note: The remainder operation (%) is also called modulo operation in other languages. Strictly speaking, however, we look at the result of the operator's operation on negative numbers,"Seeking Redundancy"Than"Take the mold"more appropriate. 5Let's talk about how the remainder is going to be calculated 94, you first calculate how many times 4 will fit into the 9:6art/Remainderinteger_2x.png7 twice times, very good, that remainder is 1 (marked in orange)8 9 in Swift, this is the expression:Ten 9%4 //equals 1 OneIn order to get the result of a% B,%The following equation is computed and the remainder is output as a result: AA = (bx multiples) +remainder - when the multiplier takes the maximum value, it will just fit into a. - the put 9 and 4 into the equation, we have 1: - 9= (4X2) +1 -The same method that I came to calculate--9%4: --9%4 //equals-1 +Put 9 and 4 into the equation,-2 is the largest integer taken: --9= (4X-2) + -1 +The remainder is-1. A atWhen a negative number B is remainder, the b symbol is ignored. This means that the results of a% B and a%-B are the same.
Swift to find the remainder operation