Wikisage, de vrije encyclopedie van de tweede generatie, is digitaal erfgoed
Wikisage is op 1 na de grootste internet-encyclopedie in het Nederlands. Iedereen kan de hier verzamelde kennis gratis gebruiken, zonder storende advertenties. De Koninklijke Bibliotheek van Nederland heeft Wikisage in 2018 aangemerkt als digitaal erfgoed.
- Wilt u meehelpen om Wikisage te laten groeien? Maak dan een account aan. U bent van harte welkom. Zie: Portaal:Gebruikers.
- Bent u blij met Wikisage, of wilt u juist meer? Dan stellen we een bescheiden donatie om de kosten te bestrijden zeer op prijs. Zie: Portaal:Donaties.
Sjabloon:Mod: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(Kopie van http://en.wikipedia.org/w/index.php?title=Template:Mod&oldid=359236315 voorlopig zonder documentatie) |
(+cat) |
||
(2 tussenliggende versies door een andere gebruiker niet weergegeven) | |||
Regel 1: | Regel 1: | ||
<includeonly>{{ {{{|safesubst:}}}#ifexpr:({{{2}}})=0|0|{{ {{{|safesubst:}}}#ifexpr:(({{{1}}})/({{{2}}}))=((({{{1}}})/({{{2}}}))round 0)|0|{{ {{{|safesubst:}}}#ifexpr:(({{{1}}})/({{{2}}}))>0 and(({{{1}}})/({{{2}}}))<1|{{ {{{|safesubst:}}}#expr:{{{1}}}}}|{{ {{{|safesubst:}}}#expr:({{{1}}})-((((({{{1}}})/({{{2}}}))-0.5)round 0)*({{{2}}}))}}}}}}}}</includeonly><noinclude> | <includeonly>{{ {{{|safesubst:}}}#ifexpr:({{{2}}})=0|0|{{ {{{|safesubst:}}}#ifexpr:(({{{1}}})/({{{2}}}))=((({{{1}}})/({{{2}}}))round 0)|0|{{ {{{|safesubst:}}}#ifexpr:(({{{1}}})/({{{2}}}))>0 and(({{{1}}})/({{{2}}}))<1|{{ {{{|safesubst:}}}#expr:{{{1}}}}}|{{ {{{|safesubst:}}}#expr:({{{1}}})-((((({{{1}}})/({{{2}}}))-0.5)round 0)*({{{2}}}))}}}}}}}}</includeonly><noinclude>{{Sjablooninfo|1= | ||
< | |||
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 [[m:Help:ParserFunctions|parser function]]. | |||
This template can be substituted. | |||
; Usage<nowiki>:</nowiki> | |||
: <Code><nowiki>{{</nowiki>mod<nowiki>|</nowiki>''dividend''<nowiki>|</nowiki>''modulus''<nowiki>}}</nowiki></code> | |||
:: Computes the modulo dynamically. | |||
: <code><nowiki>{{</nowiki>subst:mod<nowiki>|</nowiki>''dividend''<nowiki>|</nowiki>''modulus''<nowiki>}}</nowiki></code> | |||
:: Substitute the template invokation by its computed value when saving an article wiki source. | |||
; Examples with positive integer modulus<nowiki>:</nowiki> | |||
* <code><nowiki>{{mod|12|10}}</nowiki></code> = {{mod|12|10}}. | |||
* <code><nowiki>{{mod|10.1|10}}</nowiki></code> = {{mod|10.1|10}}. | |||
* <code><nowiki>{{mod|10|10}}</nowiki></code> = {{mod|10|10}}. | |||
* <code><nowiki>{{mod|2|10}}</nowiki></code> = {{mod|2|10}}. | |||
* <code><nowiki>{{mod|0|10}}</nowiki></code> = {{mod|0|10}}. | |||
* <code><nowiki>{{mod|-2|10}}</nowiki></code> = {{mod|-2|10}}. | |||
* <code><nowiki>{{mod|-10|10}}</nowiki></code> = {{mod|-10|10}}. | |||
* <code><nowiki>{{mod|-10.1|10}}</nowiki></code> = {{mod|-10.1|10}}. | |||
* <code><nowiki>{{mod|-12|10}}</nowiki></code> = {{mod|-12|10}}. | |||
; Examples with negative integer modulus<nowiki>:</nowiki> | |||
* <code><nowiki>{{mod|12|-10}}</nowiki></code> = {{mod|12|-10}}. | |||
* <code><nowiki>{{mod|10.1|-10}}</nowiki></code> = {{mod|10.1|-10}}. | |||
* <code><nowiki>{{mod|10|-10}}</nowiki></code> = {{mod|10|-10}}. | |||
* <code><nowiki>{{mod|2|-10}}</nowiki></code> = {{mod|2|-10}}. | |||
* <code><nowiki>{{mod|0|-10}}</nowiki></code> = {{mod|0|-10}}. | |||
* <code><nowiki>{{mod|-2|-10}}</nowiki></code> = {{mod|-2|-10}}. | |||
* <code><nowiki>{{mod|-10|-10}}</nowiki></code> = {{mod|-10|-10}}. | |||
* <code><nowiki>{{mod|-10.1|-10}}</nowiki></code> = {{mod|-10.1|-10}}. | |||
* <code><nowiki>{{mod|-12|-10}}</nowiki></code> = {{mod|-12|-10}}. | |||
; Examples with positive non integer modulus<nowiki>:</nowiki> | |||
* <code><nowiki>{{mod|21.5|10.5}}</nowiki></code> = {{mod|21.5|10.5}}. | |||
* <code><nowiki>{{mod|21.1|10.5}}</nowiki></code> = {{mod|21.1|10.5}}. | |||
* <code><nowiki>{{mod|21|10.5}}</nowiki></code> = {{mod|21|10.5}}. | |||
* <code><nowiki>{{mod|20.9|10.5}}</nowiki></code> = {{mod|20.9|10.5}}. | |||
* <code><nowiki>{{mod|11|10.5}}</nowiki></code> = {{mod|11|10.5}}. | |||
* <code><nowiki>{{mod|10.6|10.5}}</nowiki></code> = {{mod|10.6|10.5}}. | |||
* <code><nowiki>{{mod|10.5|10.5}}</nowiki></code> = {{mod|10.5|10.5}}. | |||
* <code><nowiki>{{mod|10.1|10.5}}</nowiki></code> = {{mod|10.1|10.5}}. | |||
* <code><nowiki>{{mod|10|10.5}}</nowiki></code> = {{mod|10|10.5}}. | |||
* <code><nowiki>{{mod|2|10.5}}</nowiki></code> = {{mod|2|10.5}}. | |||
* <code><nowiki>{{mod|0|10.5}}</nowiki></code> = {{mod|0|10.5}}. | |||
* <code><nowiki>{{mod|-2|10.5}}</nowiki></code> = {{mod|-2|10.5}}. | |||
* <code><nowiki>{{mod|-10|10.5}}</nowiki></code> = {{mod|-10|10.5}}. | |||
* <code><nowiki>{{mod|-10.1|10.5}}</nowiki></code> = {{mod|-10.1|10.5}}. | |||
* <code><nowiki>{{mod|-10.5|10.5}}</nowiki></code> = {{mod|-10.5|10.5}}. | |||
* <code><nowiki>{{mod|-10.6|10.5}}</nowiki></code> = {{mod|-10.6|10.5}}. | |||
* <code><nowiki>{{mod|-11|10.5}}</nowiki></code> = {{mod|-11|10.5}}. | |||
* <code><nowiki>{{mod|-20.9|10.5}}</nowiki></code> = {{mod|-20.9|10.5}}. | |||
* <code><nowiki>{{mod|-21|10.5}}</nowiki></code> = {{mod|-21|10.5}}. | |||
* <code><nowiki>{{mod|-21.1|10.5}}</nowiki></code> = {{mod|-21.1|10.5}}. | |||
* <code><nowiki>{{mod|-21.5|10.5}}</nowiki></code> = {{mod|-21.5|10.5}}. | |||
; Examples with nul modulus<nowiki>:</nowiki> | |||
* <code><nowiki>{{mod|2|0}}</nowiki></code> = {{mod|2|0}}. | |||
* <code><nowiki>{{mod|0|0}}</nowiki></code> = {{mod|0|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]] | |||
}} | |||
[[Categorie:Sjablonen scripting]] | |||
</noinclude> | </noinclude> |
Huidige versie van 6 jan 2012 om 11:05
De sjabloonbeschrijving hieronder wordt niet afgebeeld wanneer de sjabloon wordt geplaatst.
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.
This template can be substituted.
- 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.