Results 1 to 20 of 26
 10252010, 01:34 AM #1Member
 Join Date
 Oct 2010
 Posts
 23
 Rep Power
 0
 10252010, 01:40 AM #2
You simply take the first number: 15
And divide it by the second number: 5
15 / 5 = 3 with no remainder, so the modulus in this case would be 0.
14 / 10 = 1 with remainder of 4, so the modulus in this case would be 4.
So if you said:
Java Code:int remainder = 14 % 10;
Remainder would hold the value of 4.Sincerely, Joshua Green
Please REP if I help :)
 10252010, 01:42 AM #3
Well, just like you would do long division by hand. The % or "modulus" operator means "perform a division operation, and take the remainder, if any". where the division is typically "integer division" meaning the part divided out is the even whole number, no fractional result.
 10252010, 02:47 AM #4Member
 Join Date
 Oct 2010
 Posts
 23
 Rep Power
 0
thanks you guy so much , and how about
36 % 8 = ?
12 % 5 = ?
 10252010, 02:50 AM #5Moderator
 Join Date
 Feb 2009
 Location
 New Zealand
 Posts
 4,712
 Rep Power
 15
What value do you get when you divide 36 things into 8 piles? And what is the remainder, ie how many are left over?
 10252010, 02:51 AM #6
Sounds like a challenge! haha.
Sincerely, Joshua Green
Please REP if I help :)
 10252010, 02:53 AM #7

I second Zack's recommendation. Please at least show some effort.
 10252010, 03:16 AM #9Member
 Join Date
 Oct 2010
 Posts
 23
 Rep Power
 0
like you guy said :
12%5 =2.4 => remainder = 4 ,right ?
but in this question .
System.out.println (6.0 * 2 – 12 % 5 / 2) the correct result is : 11.0
but when i did like you guy just said :
12.0  (4/2) => the result is : 10.0
=> so please explain it , I dont understand

 10252010, 03:26 AM #11Member
 Join Date
 Oct 2010
 Posts
 23
 Rep Power
 0
 10252010, 03:28 AM #12
If you already know what a remainder is, ignore my post.
A remainder is the amount left after a number is taken out of another number a set amount of times. This is best explained by an example:
Java Code:Remainder of 26 / 6: 26  6 = 20 20  6 = 14 14  6 = 8 8  6 = 2 Since 2 is less than 6, it is the remainder. Therefore, the REMAINDER of 26/6 = 2.

 10252010, 03:32 AM #14Member
 Join Date
 Oct 2010
 Posts
 23
 Rep Power
 0
 10252010, 03:57 AM #15

 10252010, 04:04 AM #17Member
 Join Date
 Oct 2010
 Posts
 23
 Rep Power
 0
Hi ZAck ,following your answer : 26%6 will be 2 right
+What if : 6 % 26 = ? please give me an answer , Thanks Zack again

 10252010, 04:19 AM #19Moderator
 Join Date
 Feb 2009
 Location
 New Zealand
 Posts
 4,712
 Rep Power
 15
(My previous reply was actually an edit of the snarky original.)
However I'll try again...
The % operator is all about left overs. a%b means simply "how many are left over when we attempt to put a things into b (equal) piles?". So, eg, if you put 26 things into 6 piles you find that you have 2 things left over. 26%6=2.
So what happens if you attempt to put 6 things into 26 equal piles? How many will be left over?
 10252010, 04:22 AM #20Member
 Join Date
 Oct 2010
 Posts
 23
 Rep Power
 0
Similar Threads

Program in Java To calculate GCD of n numbers.?
By ankitsinghal_89 in forum New To JavaReplies: 4Last Post: 02152011, 10:23 AM 
how to discard remainder on division?
By RobertF in forum New To JavaReplies: 9Last Post: 03132009, 01:20 PM 
[SOLVED] Modulus/Remainder results
By antgaudi in forum New To JavaReplies: 9Last Post: 10132008, 03:49 AM 
BigInteger remainder results in zero
By perito in forum New To JavaReplies: 1Last Post: 03212008, 05:07 PM 
Calculate Tax in java
By toby in forum New To JavaReplies: 2Last Post: 07302007, 09:03 AM
Bookmarks