Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mod() function Bug?
Message
De
22/09/2006 11:41:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
22/09/2006 10:30:37
Calvin Smith
Wayne Reaves Computer Systems
Macon, Georgie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01156435
Message ID:
01156501
Vues:
20
>The mod command gives stange results when done this way:
>Mod(-13,4). I would expect this to return either 1 or -1 but it returns 3.
>Visual Basic return -1 for this command but Ruby return the same thing as VFP. Can someone explain this to me.... Thanks.

It's a definition by computer languages and in many languages including VFP remainder R is >= 0 and < = n2.
Mod(n1, n2) = n1 - n2[n1/n2] && where [n1/n2] is a floor function
where result should be 3.

Definition could be questioned and further VFP's implementation (ie: why would it return a negative value if it was mod(13,-4) but knowing that for your particular language you could work it.

I'm not an expert in arithmetic definitions:) Just my .02 cents.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform