Skip to main content

Celonis Product Documentation

MODULO
Description

The modulo operator returns the remainder of a division of both arguments.

The result has always the same sign as the first argument. If at least one of the input arguments is NULL, the result is NULL as well.

Both arguments can be INT or FLOAT values. If both input arguments are INTs, the return type is also an INT. Otherwise, the result is a FLOAT.

Syntax
  MODULO ( dividend, divisor )
 
  dividend % divisor
 
NULL handling

If one of the input values is NULL, the result is NULL as well.

Examples

[1]

Calculate the modulo of integers. The result has always the same sign as the first argument:

Query

Column1

         "Table1"."Dividend" % "Table1"."Divisor"
        

Input

Output

Table1

Dividend : int

Divisor : int

10

2

5

3

3

3

-5

3

5

-3

-5

-3

Result

Column1 : int

0

2

0

-2

2

-2

[2]

Calculate the modulo of integers with NULL values. If at least one input value is NULL, the result is NULL as well:

Query

Column1

         "Table1"."Dividend" % "Table1"."Divisor"
        

Input

Output

Table1

Dividend : int

Divisor : int

5

3

5

null

null

3

null

null

Result

Column1 : int

2

null

null

null

[3]

Calculate the modulo of floats. The result is always a float:

Query

Column1

         "Table1"."Dividend" % "Table1"."Divisor"
        

Input

Output

Table1

Dividend : float

Divisor : float

5.5

2.3

9.9

1.2

5.5

5.5

Result

Column1 : float

0.9

0.3

0.0

[4]

Calculate the modulo of an integer divided by a float. The result is always a float:

Query

Column1

         "Table1"."Dividend" % "Table1"."Divisor"
        

Input

Output

Table1

Dividend : int

Divisor : float

5

2.3

9

1.1

5

5.0

Result

Column1 : float

0.4

0.2

0.0

[5]

Calculate the modulo of a float divided by an integer. The result is always a float:

Query

Column1

         MODULO ( "Table1"."Dividend" , "Table1"."Divisor" )
        

Input

Output

Table1

Dividend : float

Divisor : int

5.5

2

9.0

3

5.2

5

Result

Column1 : float

1.5

0.0

0.2