Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MOD() vs % (sql-syntax)
Message
 
À
03/01/2005 13:34:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
00973817
Message ID:
00973898
Vues:
29
Tamar,
I would argue your statement and say that modulo is defined for negative numbers, but I can't find good definition of modulo (all my math text books from the university {and high school} are still in Norway). I did find some very iteresting links that discuss the very same thing:
http://mathforum.org/library/drmath/view/52343.html
http://mathforum.org/library/drmath/view/54377.html

The first link gives a very good mathematical explanation of whay you should expect when doing mod(-340,60) and VFP's answer is correct.

The second link gives some examples in C about what is going on.

Einar

>>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???
>>
>
>What you've really done wrong is tried to use modulo with a negative number. That operation isn't defined mathematically for negative numbers. However, as you've learned, programming languages let you do it anyway. It's not surprising, though, that two different engines (I'm assuming that by "SQL," you mean SQL Server, not VFP's SQL engine) give you two different results.
>
>Tamar
Semper ubi sub ubi.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform