Article ID: 138042
Article Last Modified on 10/15/2003
APPLIES TO
- Microsoft FoxPro 2.6a Standard Edition
- Microsoft Visual FoxPro 3.0 Standard Edition
This article was previously published under Q138042
SYMPTOMS
When using the MOD() function with one negative number and the expected result is the numerator, FoxPro returns the wrong value. For example, MOD(9,-10) returns -1. The correct result should be 9.
CAUSE
This occurs because the MOD() function was designed to maintain compatibility with the dBASE MOD() function, which also returns this result.
NOTE: dBASE is manufactured by Borland International Inc., a vendor independent of Microsoft; we make no warranty, implied or otherwise, regarding this product's performance or reliability.
RESOLUTION
Create a function similar to the following and use this function instead of MOD().
FUNCTION INTMOD PARAMETER x,y && where x is the numerator, y is the denominator z = x - INT(x/y)*y RETURN z && where z is the expected result
STATUS
This behavior is by design.
Additional query words: VFoxWin FoxWin akz
Keywords: KB138042