The mod function is a remainder function, its format is: mod(nExp1,nExp2), which is the remainder after dividing two numerical expressions. Special note: In EXCEL, the MOD function is used to return the remainder of the division of two numbers. The sign of the returned result is the same as the sign of the divisor.
If you want to know more related knowledge, you can click://m.sbmmt.com/faq/
Syntax:MOD(number,divisor)
Parameters:
Number is the dividend.
Divisor is the divisor. [2]
In Oracle, if divisor is 0, the function returns number directly.
Explanation:
The function MOD can be represented by the function INT: MOD(n, d) = n - d*INT(n/d)
Example:
MOD(3, 2) is equal to 1
MOD(-3, 2) is equal to 1
MOD(3, - 2) Equal to -1
MOD(-3, -2) Equal to -1
MOD(-3, 0) Equal to -3
MOD(3, 0) Equal to 3
MOD(2, 0) Equal to 2
MOD(4, 3) Equal to 1
##Algorithm
1. Find the remainder of two integers with different signs
1. Function value sign rules (sign of remainder)
mod (negative, positive)=positive, mod(-x, y): the obtained value is positive; mod(positive, negative)=negative, mod(x, -y): the obtained value is negative; Conclusion: When finding the remainder of two integers, the sign of the value is the sign of the divisor.2. Value rules: First treat the two integers as positive numbers, and then perform the division operation
①When it can be divided evenly, the value is 0 (or not displayed ) ②When it cannot be divided by integers, its value = divisor × (whole quotient 1)-divisor Example: mod(36,-10)=-4 That is: the integer of 36 divided by 10 The quotient is 3, and after adding 1, it is 4; its product with the divisor is 40; and the difference with the dividend is (40-36=4); take the sign of the divisor. So the value is -4.2. The rules for finding the remainder of two decimals:
After the dividend - (whole quotient × divisor), round off to the first decimal place. Example: mod(9,1.2)=0.6, that is: the integral quotient of 9 divided by 1.2 is 7; the product of 7 and the divisor 1.2 is 8.4; the difference between the dividend 9 and 8.4 is 0.6. So the result is 0.6. Example: mod(9,2.2)=0.2 That is: the integral quotient of 9 divided by 2.2 is 4; the product of 4 and the divisor 2.2 is 8.8; the difference between the dividend 9 and 8.8 is 0.2, so the result is 0.2 .3. In VB, it is defined as the dividend and divisor are rounded first, and then divided to find the remainder
4. In Excel, the dividend is less than or equal to the divisor The integer value rule:
Example: mod(1,3)=1, mod(2,3)=2The above is the detailed content of What does mod function mean?. For more information, please follow other related articles on the PHP Chinese website!