|
|
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: |
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 clarification. secret901-ga Search strategy: http://en.wikipedia.org/wiki/Modulo_operation Java glossary: modulus http://mindprod.com/jgloss/modulus.html | |
| |
| |
|
robalan-ga rated this answer: |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |