op:decimal-divide

Divides $decimal-var1 by $decimal-var2. The div operator invokes the decimal-divide 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-divide(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 decimal value of dividing $decimal-var1 by $decimal-var2.

Examples

Simple

Invoking decimal-divide("2.2","1.1") returns the decimal value 2 as shown in the following example query:

<decimal-divide>{op:decimal-divide("2.2","1.1")}</decimal-divide> 

The preceding query generates the following result:

<decimal-divide>2.0</decimal-divide> 

Error—Divide by Zero

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

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

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-divide operator description.