Mod/fr
Mod (modulo) calcule le reste entier de la division de deux entiers. Par exemple, l'expression "a:= 13 mod 4;" évaluera à 1 (a=1), alors que "b := 12 mod 4;" évaluera à 0 (b=0).
Le signe du résultat de l'opérateur Mod est celui de son opérande de gauche (dividende), en effet, cet opérateur est équivalent à l'expression suivante :
I mod J = I - (I div J) * JPar exemple, "c := -13 mod 4;" results in c = -1.
Mais c'est ce que fait Delphi. La norme Pascal ISO 7185 spécifie:
L'évaluation d'un terme de la forme x mod y est une erreur si y est négatif ou nul; sinon c'est un entier k tel que x mod y satisfait la relation suivante :
0 <= x mod y = x - k * y < y.See also
From the Free Pascal wiki, page "Mod/fr", as it stood on 2016-08-19 after a change by E-ric, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.