Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bug : MOD() is mistaken for nDivisor negative
Message
De
04/01/2005 04:40:03
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Bug : MOD() is mistaken for nDivisor negative
Divers
Thread ID:
00974018
Message ID:
00974018
Vues:
66
The definition of Remainder cames from :

Dividend = Quotient * Divisor + Remainder for Divisor<>0


On VFP, when Divisor < 0 the result is:
Remainder = CorrectRemainder - Divisor 
Repro:
CLEAR
#DEFINE DIVIDEND 10
#DEFINE DIVISOR   3

? "   Dividend           Divisor      Quotient      Remainder             ";
+"     Check                    Expected Remainder"

compute( DIVIDEND ,  DIVISOR)
compute( DIVIDEND , -DIVISOR)
compute(-DIVIDEND ,  DIVISOR)
compute(-DIVIDEND , -DIVISOR)

PROCEDURE compute(nDividend , nDivisor)

nQuotient   = INT(m.nDividend / m.nDivisor)
nremainder  = m.nDividend % m.nDivisor

? m.nDividend , m.nDivisor , m.nQuotient , nremainder , ;
  m.nQuotient * m.nDivisor + m.nremainder, m.nDividend - m.nQuotient * m.nDivisor
On MS SQL the % operation return expected remainders.

Fabio
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform