0

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?

8 Answers8

5

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.

qaphla
  • 4,707
  • 3
  • 20
  • 31
1

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

mlorbetske
  • 5,529
  • 2
  • 28
  • 40
LZR
  • 948
  • 10
  • 28
0

27 is (16 * 1) + 11. The eleven here is the "remainder". This is how you get modulo

gerrytan
  • 40,313
  • 9
  • 84
  • 99
0

You need to check how many times 16 goes in 27 (which is 1), then you simply decrease:

27 - (16 * 1) = 11

BobTheBuilder
  • 18,858
  • 6
  • 40
  • 61
0

Follow the following steps

  1. Divide the numerator by denominator
  2. If the remainder is greater than denominator { than make remainder the new numerator and repeat steps 1, 2 }else{

                     remainder is the  result
                      } 
    
Sanyam Goel
  • 2,138
  • 22
  • 40
0

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.

bjackfly
  • 3,236
  • 2
  • 25
  • 38
0

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
Ruchira Gayan Ranaweera
  • 34,993
  • 17
  • 75
  • 115
0

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.

Eamonn O'Brien-Strain
  • 3,352
  • 1
  • 23
  • 33