0

How modulus work? I don't get it in some ways

24th Sep 2016, 1:35 AM
Kim Villamor
Kim Villamor - avatar
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
24th Sep 2016, 2:20 PM
Muhamad Iqbal Nurmanditya
Muhamad Iqbal Nurmanditya - avatar
+ 1
Modulus operator just find the remainder from a division.
24th Sep 2016, 6:21 PM
BasicCoder
BasicCoder - avatar
0
So how about 9 % 2 is 1? Is't because 9 / 2 = 4.5 and modulo is 0.5 rounded to 1?
26th Sep 2016, 8:43 AM
bulanDev
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 🍻
28th Sep 2016, 1:36 AM
Bruno de Oliveira
Bruno de Oliveira - avatar
0
7021446004
29th Sep 2016, 6:42 PM
Parvez Shaikh
Parvez Shaikh - avatar
0
good q
16th Oct 2016, 5:30 AM
Ankit Jain
Ankit Jain - avatar
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
15th Dec 2016, 3:56 AM
Jake
0
modulus work as divide in same way
23rd Mar 2018, 2:02 PM
Ankit Jain
Ankit Jain - avatar