+ 1

I don't believe I understand the modulus operator very well.

15th Jan 2016, 4:13 AM
Sandra Pérez
Sandra Pérez - avatar
6 odpowiedzi
+ 12
@sandra pérez The modulus operator is very different from division. it does divide, but that number is discarded, whatever is left is printed. in the example of 25%7 we get this; 25/7 does not give a whole number, 21/7 is the closest since we cant increase the starting value of 25. this results in 3, but is discarded. 25-21 is all that matters here, and the answer to that is 4. this can be used to calculate for example; the number of leftover days in a year when you divide the days in a year (365) by the number of weeks in a year (52). 365%52 becomes 364/52 to make the result a whole number. 365-364=1, in this case 1 is printed. Hope this helps:)
27th Jan 2016, 2:14 PM
Roy
+ 8
In short, it calculate the remainder in a division.
11th Jun 2016, 3:21 PM
Thomas Ho
Thomas Ho - avatar
+ 2
For any positive real x and y where x > y, the modulus operator is defined as follows: x % y = x - (y * floor(x / y)) Where floor(n) is the largest integer less than or equal to argument n.
30th Jun 2016, 5:29 AM
Errenium
Errenium - avatar
0
It is used to find the remainder of a division operation. For example 9 % 4 = 1, because the closest 4 can get to 9 is 4 * 2 which is 8, with a remainder of 1.
8th Oct 2016, 2:42 AM
Solus
Solus - avatar
0
just you remember one thing...division operator(/) gives you quotient and the modulus operator(%) gives you the remainder...that's it..
17th Oct 2016, 5:19 AM
bhogavilli sai surendra
0
remainder is the value
13th Nov 2016, 8:45 PM
iGhost Asking Hungarians
iGhost Asking Hungarians - avatar