0

Anyone i'm always having trouble with %(modulus) i'm tryng to break how it works but it such impossible for me. Until i get how some awful ex. Can you explain how it count detaily?

31st Jul 2016, 1:00 AM
Elvin Tech
Elvin Tech - avatar
9 Answers
+ 5
Please stop providing terrible examples. Modulus is simply the remainder of a division operation. In the C# tutorials we're using Modulus to determine if there is a remainder (eg. != 0) ... So for example we can evaluate true or false with an operation like if (12%5 != 0) which would evaluate to true because the remainder is 2... not equal to 0. If we did if (12%5 == 0) it would evaluate false. Look at simple division operations. 12 divided by 5 equals 2 with a remainder of 2 (or 12%5 == 2). 15 divided by 2 is equal to 7 with a remainder of 1 (or 15%2 == 1).
31st Jul 2016, 11:52 AM
Mike
Mike - avatar
+ 1
so if 5/2 its means the reminder is 1?
31st Jul 2016, 4:14 AM
Elvin Tech
Elvin Tech - avatar
0
ya while dividing any with number . We don't have go for decimal just how much number are left for division they are said to be remainder
31st Jul 2016, 6:48 AM
Heart Bracker
Heart Bracker - avatar
0
Modulos is the remainder of a division. If you would use number that returns a float value, you will return a interger. 5%2 = 1 When you use modulas you first divide 5/2 = 2.5. Hmm, this is a float value. How can I get this to a interger? Well I can not increase any value on the division. So 6/2 does not work. But what if I go down to the first divisible value that returns an interger? 4/2 = 2. This will mean that the remainder is 1. 5-4 = 1.
31st Jul 2016, 7:47 AM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
0
If you assign float value then it come with decimal else with out decimal ...
31st Jul 2016, 8:55 AM
Heart Bracker
Heart Bracker - avatar
0
thanks for the explanation :)
31st Jul 2016, 11:32 AM
Elvin Tech
Elvin Tech - avatar
0
ya that's it you got it
31st Jul 2016, 12:58 PM
Heart Bracker
Heart Bracker - avatar
0
wow, thx
1st Aug 2016, 7:16 AM
Elvin Tech
Elvin Tech - avatar
- 1
% modules is just like an division it's show the remainder while we divide any two number for example 2/2 is 1 but after that there is no remainder next example 5 / 2 it's answer is 2.5 as you can see we have 2 +2 + 1 = 5 while divide by 2 at last we have to look only for remainder only
31st Jul 2016, 4:07 AM
Heart Bracker
Heart Bracker - avatar