Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MOD() vs % (sql-syntax)
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00973817
Message ID:
00974004
Views:
27
Hi Einar!

Thanks for explaination - I didn't know this.

>Robert,
>Negative 2 should be the correct answer if I remember correctly from high school math. I took a look at what the help file had to say about MOD():
>
>MOD( ) Function
>Divides one numeric expression by another numeric expression and returns the remainder.
>
>MOD(nDividend, nDivisor)
>Return Values
>Numeric
>
>Parameters
>nDividend
>Specifies the dividend. The number of decimal places in nDividend determines the number of decimal places in the return value.
>nDivisor
>Specifies the divisor. A positive number is returned if nDivisor is positive, and a negative number is returned if nDivisor is negative.
>
>
>If the dividend is negative the divisor also has to be negative to get the desired result.
>Something like this would work:
>
>iDividend = -2
>iDivisor = 12
>?mod(iDividend, iif(iDividend<0, -iDivisor, iDivisor))
>
>
>Were you expecting negative 2 from VFP as well?
>
>Einar
>
>>Hi all!
>>
>>I've encountered a strange behaviour when using MODULO-function.
>>
>>VFP8:
>>MOD(10-12,12) = 10
>>
>>SQL:
>>(10-12) % 12 = -2
>>
>>I need to use Modulo in my sql-syntax - what have I done wrong???
>>
>>Thanks for help!
robert.oh.
Previous
Reply
Map
View

Click here to load this message in the networking platform