Skip to main content

PQL46 (PQL Function Library - CPM 4.6)

MODULO

Applies to: CELONIS 4.0 CELONIS 4.2 CELONIS 4.3 CELONIS 4.4 CELONIS 4.5 CELONIS 4.6

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

(Since: CELONIS 4.5)

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.9000000000000004

0.3000000000000007

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

Output

Column1 : FLOAT

0.40000000000000036

0.1999999999999993

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.20000000000000018