Function Mod() Foundation
Determines the modulus of two numbers in the same manner as dBASE III PLUS.
Syntax
Mod( <nDividend>, <nDivisor> ) --> nRest
Parameters
<nDividend>
<nDividend> is the numerator of the division.
<nDivisor>
<nDivisor> is the denominator of the division.
Return
The return value of Mod() is the numeric remainder of division of <nDividend> by <nDivisor>.
Description
The numeric function Mod() is identical to the function with the same name in dBASE III PLUS. It is replaced in Xbase++ with the Modulus operator (%) and should not be used. The results of Mod() and the modulus operator are different. The example demonstrates the differences between the two.
Examples
// The example contrasts various modulus operations with Mod()
// and the modulus operator, demonstrating the differences
// between them.
PROCEDURE Main
** Deviating results
? Mod(-1, 3) , -1 % 3 // result: 2.00 -1
? Mod( 1,-3) , 1 % -3 // result: -2.00 1
? Mod(-2, 3) , -2 % 3 // result: 1.00 -2
? Mod( 2,-3) , 2 % -3 // result: -1.00 2
? Mod( 3,-2) , 3 % -2 // result: -1.00 1
? Mod(-3, 2) , -3 % 2 // result: 1.00 -1
** Same results
? Mod( 3, 2) , 3 % 2 // result: 1.00 1
? Mod(-3,-2) , -3 % -2 // result: -1.00 -1
? Mod(27, 6) , 27 % 6 // result: 3.00 3
? Mod(27, 3) , 27 % 3 // result: 0.00 0
? Mod(27, 2) , 27 % 2 // result: 1.00 1
? Mod(27,30) , 27 % 30 // result: 27.00 27
? Mod(3.2,2.1) , 3.2 % 2.1 // result: 1.10 1.10
RETURN
Feedback
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.