All Products
Search
Document Center

MOD

Last Updated: Jun 18, 2021

The MOD function returns the remainder of x that is divided by y.

Notice

When the REMAINDER (x,y) and MOD (x,y) functions perform operations, the same formula result=x-y*(x/y) is used. The difference between MOD (x,y) and REMAINDER (x,y) is that the processing methods are different when x/y is calculated. ROUND(x/y) is used in the REMAINDER (x,y) function, whereas FLOOR(x/y) is used in the MOD (x,y) function.

Syntax

MOD (x,y)

Parameters

Parameter

Description

x,y

x and y are the expressions of the numeric types: NUMBER, FLOAT, BINARY_FLOAT, and BINARY_DOUBLE.

Return type

The return type is the same as the data type of the parameter that has higher numeric precedence.

Examples

This example shows the result of calculating the remainder of 23/8 and 24/8.

Execute the following statement:

SELECT MOD(23,8), MOD(24,8) FROM DUAL;

The following query result is returned:

+-----------+-----------+
| MOD(23,8) | MOD(24,8) |
+-----------+-----------+
|         7 |         0 |
+-----------+-----------+