Sign in Join
Wiki copytemporary

Mod/fr: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11Mod (**mod**ulo) 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).
22
33cf [language reference](http://www.freepascal.org/docs-html/ref/refsu29.html):
44
55
66Le 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 :
77
88` I mod J = I - (I div J) * J `
99
1010Par exemple, "c := -13 mod 4;" results in c = -1.
1111
1212Mais c'est ce que fait Delphi. La norme Pascal ISO 7185 spécifie:
1313
1414
1515L'é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 :
1616
1717` 0 <= x mod y = x - k * y < y.`
1818
1919## See also
2020
2121- [[Div/fr|Div]]
2222
23-\
24-
2523---
2624*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](/wiki-contact).*
2725Category: FPC/fr
2826Category: Pascal/fr
2927Category: Reserved words/fr

Back to history