The module operator


#1

hello,
any one to help me here? i am just new to java.

For example, 15 % 6 will return the value of 3, because that is the remainder left over after dividing 15 by 6. where does 3 coming from?

thank you


#2

this is not specifically related to Java, its just a math concept.

Well, we could use the table of 6 to determine the biggest possible division:

is 6 less or equal to 15? yes
is 12 less or equal to 15? yes
is 18 less or equal to 15? no

so the biggest possible division by 6 of a whole number less then 15 is 12. So the remainder is 3 (15 - 12)

otherwise, you can google this as well, its just related to math


#3

Thank you for your support.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.