So i'm trying to understand modulo and I have been struggling due to a small learning disorder I have. My question is how do you determine the remainder of a modulo equation. If 27%16=11 how do you get the eleven is what I don't understand?
-
This question appears to be off-topic because it is about math. – Mat Aug 21 '13 at 05:00
-
"modulus" means remainder. – user541686 Aug 21 '13 at 05:03
-
1same thing here http://stackoverflow.com/questions/2664301/how-does-modulus-divison-work – Ruchira Gayan Ranaweera Aug 21 '13 at 05:15
-
possible duplicate of [Modulus in Java](http://stackoverflow.com/questions/16237319/modulus-in-java) – Kon Aug 21 '13 at 05:20
8 Answers
If you have a % b = c, then c is the remainder when a is divided by b. That is, if you repeatedly subtract b from a until you can't subtract any more without making it negative, that resulting number will be c.
Alternately, if you know how the / operator works in most programming languages with integer division, if a % b = c, then c is the number such that ((a / b) * b) + c = a.

- 4,707
- 3
- 20
- 31
-
1good answer, to summarise, mod is the remainder of a division of two numbers. – pstanton Aug 21 '13 at 05:11
Modulus is the "remainder" operator.
Consider the division
27 / 16 = 1 r 11
27
is divided by 16
evenly 1
time, and has a remainder (denoted by the r
) of 11
. In the context of integer division then
27 / 16 = 1 <-- The integral number of times the right operand divides evenly into
the left (the number left of the 'r' from above)
27 % 16 = 11 <-- The 'remainder' of the division of left value by the right
(the number right of the 'r' above)
Algebraically if k = x % y
, then x - k
is evenly divisible by y

- 5,529
- 2
- 28
- 40

- 948
- 10
- 28
-
This is a very low quality comment; you should add explanation to clarify what you are doing. – Jeroen Vannevel Aug 21 '13 at 05:21
27 is (16 * 1) + 11. The eleven here is the "remainder". This is how you get modulo

- 40,313
- 9
- 84
- 99
You need to check how many times 16 goes in 27 (which is 1), then you simply decrease:
27 - (16 * 1) = 11

- 18,858
- 6
- 40
- 61
Follow the following steps
- Divide the numerator by denominator
If the remainder is greater than denominator { than make remainder the new numerator and repeat steps 1, 2 }else{
remainder is the result }

- 2,138
- 22
- 40
16 x 2 = 32 which is greater than 27.
16 x 1 = 16 which is less than 27 by 11.
16 < 27 < 32
Therefore 16 divides into 27 one time. Afterwards you have 27 - 16 this is what is left over after dividing by 16 you have 27 - 16 = 11.
27/27 = 1 with no left over so there is no remainder so 27 % 27 = 0;
27 % 16 = 11 because 16 will not go evenly into 27 but has a left over of 11.
Please add any follow up comment or questions and I will be happy to explain further. I know these things can be tricky when you are first learning them.

- 3,236
- 2
- 25
- 38
Ok, Let's do this in basic manner.
now I need to divide 27
by 16
, 27/16
. Now 1X16=16, 2X16=32
.Now 27<32
, then by dividing 27/16
we can have a value between 1
and 2
. In other word there is a remaining part, 27 -1X16=11
.
In java
if we want to take this remainder at once, we use %(modulo division)
then 27%16=11
27 / 16 = 1, remainder 11 In java 27%16=11

- 34,993
- 17
- 75
- 115
When you divide one number by another you can do it in two ways in a language like Java.
If you use floating point numbers by doing 27.0 / 16.0
you get a number with whole and fractional parts, such as 1.6878
which is 1+11/16
where 11
is known as the remainder.
If you use integer numbers then you have to use two different operations to get the whole and fractional numbers. You can do 27 / 16
to get the whole number result 1
, and you can do 27 % 16
and get the remainder of 11
.

- 3,352
- 1
- 23
- 33