Oracle / PLSQL: MOD Function
This Oracle tutorial explains how to use the Oracle/PLSQL MOD function with syntax and examples.
Description
The Oracle/PLSQL MOD function returns the remainder of m divided by n.
Syntax
The syntax for the MOD function in Oracle/PLSQL is:
MOD( m, n )
Parameters or Arguments
- m
- Numeric value used in the calculation.
- n
- Numeric value used in the calculation.
Calculation
The MOD is calculated as follows:
m - n * floor(m/n)
Returns
The MOD function returns a numeric value.
The MOD function returns m if n is 0.
Note
- The MOD function uses the FLOOR function in its formula.
- See also the REMAINDER function.
Applies To
The MOD function can be used in the following versions of Oracle/PLSQL:
- Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
Example
Let's look at some Oracle MOD function examples and explore how to use the MOD function in Oracle/PLSQL.
For example:
MOD(15, 4) Result: 3 MOD(15, 0) Result: 15 MOD(11.6, 2) Result: 1.6 MOD(11.6, 2.1) Result: 1.1 MOD(-15, 4) Result: -3 MOD(-15, 0) Result: -15
Advertisements