0
How modulus work? I don't get it in some ways
8 Réponses
+ 4
example:
10 modulus 3, is 1 . because aritmathic 3x3 = 9.
10-9 is 1.
12 modulus 3 is 0. because 3×4=12
12-12 is 0
15 modulus 4 is 3. because 4×3=12
15-12 is 3
+ 1
Modulus operator just find the remainder from a division.
0
So how about 9 % 2 is 1? Is't because 9 / 2 = 4.5 and modulo is 0.5 rounded to 1?
0
No. It means that 4 * 2 = 8 so the remaining is 1. You can never have or use fractional numbers on modulus calcs...
I hope I have helped you. Cheers 🍻
0
7021446004
0
good q
0
@vivi its because multiplications of the $num (in our case 2) so multiplications of 2 tell us that it cannot be 2x5 as that=10 and our num is only 9.
so 2x4=8 and our remainder is 1.
therefore 9%2=1
0
modulus work as divide in same way