Google Answers Logo
View Question
Q: modulus division in Java ( Answered 4 out of 5 stars,   0 Comments )
Subject: modulus division in Java
Category: Computers > Programming
Asked by: robalan-ga
List Price: $20.00
Posted: 25 Sep 2005 12:45 PDT
Expires: 25 Oct 2005 12:45 PDT
Question ID: 572449
I'm learning Java programming as a hobby. The modulo operator is confusing me.
I have been researching modulus division and can understand 60 mod 60
giving a result of 0.
But why does 15 mod 60 = 15 ?
I would expect 15 divided by 60 to equal 0.25.
Please help, I've been searching the internet for the past few days
without any luck.
Subject: Re: modulus division in Java
Answered By: secret901-ga on 25 Sep 2005 13:19 PDT
Rated:4 out of 5 stars
Hi robalan-ga,

In Java and other programming languages, the modulo operator, usually
represented by the symbol "%" or "mod", finds the remainder of
division by one number by another.

For example, 60 % 60 = 0 because when you divide 60 into 60, the remainder is 0.

By the same reasoning, 15 % 60 = 15 because 15/16 = 0 with a remainder of 15.

Thus, the result of a modulo operation between two integers, for
example a % b is always an integer between 0 and b-1.

I hope this clears up the confusion.  If you still need help
understanding this concept, please let me know via a request for


Search strategy:
Java glossary: modulus

Clarification of Answer by secret901-ga on 25 Sep 2005 13:20 PDT
Oops, in the above answer, "15/16" should be changed to "15/60"

Thank you,

Request for Answer Clarification by robalan-ga on 26 Sep 2005 01:26 PDT
hi secret901-ga,

I think I understand it.
So the 15 % 60 = 15 because 15 goes into sixty 0.25 times. 0.25 is not
an integer. So 15 goes into sixty zero times leaving 15.
Is this correct?

Clarification of Answer by secret901-ga on 26 Sep 2005 07:11 PDT
Hi robalan-ga,

Your reasoning is correct.  The modulo operator finds the remainder of
a division, not the quotient.  Think back to the days in elementary
school before you haven't learned decimals yet.  When you first
learned division, when you divide two numbers you get an integer
quotient and a remainder.

If you still need help understanding this concept, please let me know
before rating this answer.

robalan-ga rated this answer:4 out of 5 stars

There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy