What is the function of mod?
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.
mod expression
The mod function is a remainder function. Its format is: mod(nExp1,nExp2), which is a division operation between two numerical expressions. The remainder after. Then: finding the remainder of two integers with the same sign is exactly the same as finding the remainder of two positive numbers that you know (that is, the algorithm for two negative integers is the same as that of two positive integers).
Syntax:
MOD(number,divisor)
Parameters:
Number is the dividend.
Divisor is the divisor.
In Oracle, if divisor is 0, the function returns number directly.
Explanation:
The function MOD can be expressed by borrowing the function INT:
MOD(n, d) = n - d*INT(n/d) [3]
Example:
MOD(3, 2) is equal to 1
MOD(-3, 2) is equal to 1
MOD(3, -2) is equal to -1
MOD(-3, -2) is equal to -1
MOD(-3, 0) is equal to -3
MOD(3, 0) is equal to 3
MOD(2, 0) is equal to 2
MOD(4, 3) is equal to 1
And in Excel, the divisor cannot be 0, otherwise an error will be reported.
MOD(3, -2) is equal to -1 (the same sign as the following number)
MOD(3, 0) reports an error and the output result is #DIV/0!
The above is the detailed content of What is mod function?. For more information, please follow other related articles on the PHP Chinese website!