op:decimal-mod

Return the remainder of dividing $decimal-var1 by $decimal-var2. The mod operator invokes the decimal-mod operator.

If the value of $decimal-var2 is equal to zero, the TransformException exception is raised with the RT_DIV_ZERO fault code. The following error message is displayed in the mapper:

Error occurred while executing XQuery: division by zero 

Signatures

op:decimal-mod(xs:decimal $decimal-var1, xs:decimal $decimal-var2) —> xs:decimal

Arguments

Data Type
Argument
Description

xs:decimal

$decimal-var1

Represents a decimal number, for example: 1.1.

xs:decimal

$decimal-var2

Represents a decimal number, for example: 1.1.

Returns

Returns the remainder of dividing $decimal-var1 by $decimal-var2.

Examples

Simple

Invoking decimal-mod("2.1","2.0") returns the decimal value .1 because 2.1 divided by 2.0 results in 1 with the remainder: .1. The remainder: .1 is returned as shown in the following example query:

<decimal-mod>{op:decimal-mod("2.1","2.0")}</decimal-mod> 

The preceding query generates the following result:

<decimal-mod>0.1</decimal-mod> 

Error—Divide by Zero

Invoking decimal-mod("2.2","0")throws the TransformException exception with the RT_DIV_ZERO fault code as shown in the following example query:

<decimal-mod>{op:decimal-mod("2.2","0")}</decimal-mod> 

The following error message is displayed in the mapper:

Error occurred while executing XQuery: division by zero 

Related Topics

W3C decimal data type description.

W3C numeric-mod operator description.