Template:Mod/Doc

From PCSAR

(Difference between revisions)
Jump to: navigation, search
Current revision (21:03, 7 February 2013) (edit) (undo)
(See also)
 
Line 57: Line 57:
* <code><nowiki>{{mod|0|0}}</nowiki></code> = {{mod|0|0}}.
* <code><nowiki>{{mod|0|0}}</nowiki></code> = {{mod|0|0}}.
* <code><nowiki>{{mod|-2|0}}</nowiki></code> = {{mod|-2|0}}.
* <code><nowiki>{{mod|-2|0}}</nowiki></code> = {{mod|-2|0}}.
-
 
-
== See also ==
 
-
* [[m:Help:Mod, round, floor, ceil, trunc#Mod|mod operator for <code>#expr</code> parser function]]
 
based on http://en.wikipedia.org/wiki/Template:Mod
based on http://en.wikipedia.org/wiki/Template:Mod

Current revision

The template {{Mod}} implements the mathematical modulo operator. The returned result is always of the same sign as the modulus or nul, and its absolute value is lower than the absolute value of the modulus. However, this template returns 0 if the modulus is nul (this template should never return a division by zero error). This template is not the same as the mod operator in the #expr parser function.

Usage:
{{mod|dividend|modulus}}
Computes the modulo dynamically.
{{subst:mod|dividend|modulus}}
Substitute the template invokation by its computed value when saving an article wiki source.
Examples with positive integer modulus:
  • {{mod|12|10}} = 2.
  • {{mod|10.1|10}} = 0.1.
  • {{mod|10|10}} = 0.
  • {{mod|2|10}} = 2.
  • {{mod|0|10}} = 0.
  • {{mod|-2|10}} = 8.
  • {{mod|-10|10}} = 0.
  • {{mod|-10.1|10}} = 9.9.
  • {{mod|-12|10}} = 8.
Examples with negative integer modulus:
  • {{mod|12|-10}} = -8.
  • {{mod|10.1|-10}} = -9.9.
  • {{mod|10|-10}} = 0.
  • {{mod|2|-10}} = -8.
  • {{mod|0|-10}} = 0.
  • {{mod|-2|-10}} = -2.
  • {{mod|-10|-10}} = 0.
  • {{mod|-10.1|-10}} = -0.1.
  • {{mod|-12|-10}} = -2.
Examples with positive non integer modulus:
  • {{mod|21.5|10.5}} = 0.5.
  • {{mod|21.1|10.5}} = 0.1.
  • {{mod|21|10.5}} = 0.
  • {{mod|20.9|10.5}} = 10.4.
  • {{mod|11|10.5}} = 0.5.
  • {{mod|10.6|10.5}} = 0.1.
  • {{mod|10.5|10.5}} = 0.
  • {{mod|10.1|10.5}} = 10.1.
  • {{mod|10|10.5}} = 10.
  • {{mod|2|10.5}} = 2.
  • {{mod|0|10.5}} = 0.
  • {{mod|-2|10.5}} = 8.5.
  • {{mod|-10|10.5}} = 0.5.
  • {{mod|-10.1|10.5}} = 0.4.
  • {{mod|-10.5|10.5}} = 0.
  • {{mod|-10.6|10.5}} = 10.4.
  • {{mod|-11|10.5}} = 10.
  • {{mod|-20.9|10.5}} = 0.1.
  • {{mod|-21|10.5}} = 0.
  • {{mod|-21.1|10.5}} = 10.4.
  • {{mod|-21.5|10.5}} = 10.
Examples with nul modulus:
  • {{mod|2|0}} = 0.
  • {{mod|0|0}} = 0.
  • {{mod|-2|0}} = 0.

based on http://en.wikipedia.org/wiki/Template:Mod

Personal tools