Examples are as follows:
Class test{
System.out.println ("1/10=" +1/10);
System.out.println ("1%10=" +1%10);
System.out.println ("2/10=" +2/10);
System.out.println ("2%10=" +2%10);
}
The results are as follows
1/10= 0
1%10= 1
2/10= 0
2%10= 2
Self-summary analysis: In programming if "dividend" is less than "divisor", "quotient" (that is,/) is all 0, "remainder" (that is,%) is "dividend".
A programming problem that extends from this
public class Test {
public static void Main (string[] args) {
int i = 0;
while (true) {
i = (i+1)%10;//divisor is 10, the remainder will never exceed 10, so the output number will always be less than 10.
System.out.println (i);
}
}
}
This is a programming question with an infinite output of 10 or less digits.
Because the divisor is 10, so no matter how much I grow, the rest of the number is not more than 10, so the result is always controlled between 0-9.
Examples are as follows: I =10, i%10=0;
i=23,i%10=3;
i=36,i%10=6;
I=100023,i%10= 3;
No matter how big the dividend, the remaining number is the number on the rightmost single digit in the quotient.
Like 1/10, it's 01,2/10, it's 02.
10/10 the above is 10 bits for a bit 0, so the quotient is 0
32/10, above 10 bit is 3, digit is 2, therefore 32%10=2;
Never find out why this is to be calculated, just do a little analysis according to the rules, busy record down.
If someone finds a mistake, make sure to leave a message.
Questions about the divisor, divisor, quotient, and remainder in programming