op:numeric-integer-divide

Divides $integer-var1 by $integer-var2 and returns the resulting integer. If $integer-var2 is not divided evenly by $integer-var1, the remainder is dropped—no rounding occurs. The idiv operator is invoked by the numeric-integer-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:numeric-integer-divide(xs:integer $integer-var1, xs:integer $double-var2) —> xs:integer

Arguments

Data Type
Argument
Description

xs:integer

$integer-var1

Represents a integer number, for example: 1.

xs:integer

$integer-var2

Represents a integer number, for example: 1.

Returns

Returns the integer result of dividing $integer-var1 by $integer-var2. If $integer-var2 is not divided evenly by $integer-var1, the remainder is dropped—no rounding occurs.

Examples

No Remainder

Invoking op:numeric-integer-divide("4","2") returns the integer: 2 as shown in the following example query:

<numeric-integer-divide>{
	op:numeric-integer-divide("4","2")
}</numeric-integer-divide> 

The preceding query generates the following result:

<numeric-integer-divide>2</numeric-integer-divide> 

Note: The integer: 4 is divided eventually by the integer: 2 with no remainder.

Throw Away Remainder

Invoking op:numeric-integer-divide("5","2") returns the integer: 2 as shown in the following example query:

<numeric-integer-divide>{
	op:numeric-integer-divide("5","2")
}</numeric-integer-divide> 

The preceding query generates the following result:

<numeric-integer-divide>2</numeric-integer-divide> 

Note: The remainder is discarded.

Error—Divide by Zero

Invoking op:numeric-integer-divide("2","0") throws the TransformException exception with the RT_DIV_ZERO fault code as shown in the following example query:

<numeric-integer-divide>{
	op:numeric-integer-divide("2","0")
}</numeric-integer-divide> 

The following error message is displayed in the mapper:

Error occurred while executing XQuery: division by zero 

Related Topics

W3C integer data type description.

W3C numeric-integer-divide operator description.