Template>Verdy p |
|
(46 intermediate revisions by 26 users not shown) |
Line 1: |
Line 1: |
| <includeonly>{{#ifexpr:({{{1}}})=(({{{1}}})round 0)|{{#expr:{{{1}}}}}|{{#ifexpr:({{{1}}})>0|{{#expr:((({{{1}}})+0.5)round 0)-1}}|{{#expr:-((0.5-({{{1}}}))round 0)}}}}}}</includeonly><noinclude>{{Template documentation}} | | <span style="font-size:{{{2|1em}}}">⌊</span>{{{1}}}<span style="font-size:{{{2|1em}}}">⌋</span><noinclude>{{Documentation|content= |
| Implements the mathematical [[floor function]], i.e. returns the input value if it is an integer, otherwise returns the largest integer below the input value.
| | == Description == |
| | Displays the parameter wrapped in floor symbols. This template is for display, not calculation. |
|
| |
|
| For negative numbers, the decimals will be simply dropped. For positive numbers, it will also truncate the displayed decimals but the integer part of the absolute value displayed is incremented. This is the mathematical definition of the IEEE rounding mode ''toward plus infinite''.
| | == Examples == |
| | {{demo|<nowiki>{{floor|45.23}}</nowiki>}} |
| | {{demo|<nowiki>{{floor|''x''}}</nowiki>}} |
| | {{demo|<nowiki>{{floor|{{sfrac|2''a''|''b''}}}}</nowiki>}} |
| | {{demo|<nowiki>{{floor|{{sfrac|2''a''|''b''}}|2em}}</nowiki>}} |
| | {{demo|<nowiki>{{floor|{{sfrac|2''a''|''b''}}|larger}}</nowiki>}} |
| | {{demo|<nowiki>{{floor|{{sfrac|2''a''|''b''}}|large}}</nowiki>}} |
| | {{demo|<nowiki>{{math|{{floor|{{sfrac|2''a''|''b''}}}}}}</nowiki>}} |
| | {{demo|<nowiki>{{bigmath|{{floor|{{sfrac|2''a''|''b''}}}}}}</nowiki>}} |
|
| |
|
| ; Usage<nowiki>:</nowiki>
| | == See also == |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}|</tt>''value''<tt><nowiki>}}</nowiki></tt>
| | {{Math templates|notation}} |
|
| |
|
| ; Examples<nowiki>:</nowiki>
| | [[Category:Mathematical formatting templates]] |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>3.9<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|3.9}}.
| | }}</noinclude> |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>3.5<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|3.5}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>3.1<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|3.1}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>3.0<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|3.0}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>1.0<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|1.0}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0.9<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|0.9}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0.5<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|0.5}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0.1<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|0.1}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0.0<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|0.0}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0.1<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-0.1}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0.5<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-0.5}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0.9<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-0.9}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-1.0<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-1.0}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-3.0<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-3.0}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-3.2<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-3.2}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-3.5<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-3.5}}.
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-3.9<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-3.9}}.
| |
| | |
| ; Known bug (should appear extremely rarely as this goes beyond the precision of math performed in pages using this template)
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0.999999999999999<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-0.999999999999999}} (OK).
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0.9999999999999999<nowiki>}}</nowiki></tt> = <span style="color:red">{{{{PAGENAME}}|-0.9999999999999999}}</span> (wrong for now and unexplainable, how to correct it?).
| |
| * <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-1.9999999999999999<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-1.9999999999999999}} (OK).
| |
| ''Note that this bug is not in this template itself, and not even in the MediaWiki software, but comes from the current version of the PHP language used to run this software. It may not affect other wikis, depending on the PHP version used.''
| |
| | |
| ; See also<nowiki>:</nowiki>
| |
| * [[Template:Ceil]]
| |
| | |
| [[Category:Templates using ParserFunctions|{{PAGENAME}}]] | |
| [[Category:Mathematical templates|{{PAGENAME}}]]
| |
| | |
| [[fr:Modèle:Floor]]
| |
| | |
| </noinclude> | |