Click or drag to resize

Mod Function

X#
Return the remainder of one number divided by another number.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION Mod(
	nDividend AS USUAL,
	nDivisor AS USUAL
) AS USUAL
Request Example View Source

Parameters

nDividend
Type: Usual
The dividend of the division operation.
nDivisor
Type: Usual
The divisor of the division operation.

Return Value

Type: Usual
A number representing the remainder of nDividend divided by nDivisor.
Remarks
Mod() is not implemented using the X# modulus operator (%). Note that there are differences between the Mod() function and the modulus operator, which are described in the following table: Dividend Divisor Modulus Operator Mod() function 3 0 Error 3 3 -2 1 -1 -3 2 -1 1 -3 0 Error -3 -1 3 -1 2 -2 3 -2 1 2 -3 2 -1 1 -3 1 -2
Tip Tip
In dBASE III PLUS, a 0 divisor returns the dividend for every value of the dividend. In versions of CA-Clipper prior to Summer '87, a 0 divisor returned 0 for all dividends. In X#, by contrast, the modulus of any dividend using a 0 divisor causes a runtime error.
Examples