Template:Floor: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>AdiJapan
fixed explanation
Ookami (talk | contribs)
m 61 revisions imported
 
(33 intermediate revisions by 18 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}}
{{{1}}}<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 positive numbers, the decimals will be simply dropped. For negative 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 minus infinite''.
== Examples ==
{{demo|<nowiki>{{Floor|45.23}}</nowiki>}}
{{demo|<nowiki>{{Floor|''x''}}</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.99999999999999983<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|0.99999999999999983}} (OK).
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0.99999999999999984<nowiki>}}</nowiki></tt> = <span style="color:red">{{{{PAGENAME}}|0.99999999999999984}}</span> (wrong but comes from limited floating point precision, the input is 1-''epsilon'', adding 0.5 yields 1.5-''epsilon'' which rounds to 2 exactly, then subtracting 1 gives 1 exactly).
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0.99999999999999999<nowiki>}}</nowiki></tt> = <span style="color:red">{{{{PAGENAME}}|0.99999999999999999}}</span> (wrong but comes from limited floating point precision, the input is considered equal to the exact integer 1).
 
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0.99999999999999983<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-0.99999999999999983}} (OK).
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0.99999999999999984<nowiki>}}</nowiki></tt> = <span style="color:red">{{{{PAGENAME}}|-0.99999999999999984}}</span> (wrong but comes from limited floating point precision, the input is not exactly equal to the integer -1, but subtracting 0.5 yields -1.5 exactly due to precision limits, which then rounds to -2).
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0.99999999999999999<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-0.99999999999999999}} (OK, the input is considered equal to the exact integer -1, so this exact -1 integer is returned).
{| class="prettytable" style="text-align: left;"
! num || floor || ceil
|-
| -0.999999999999998334665463062265 || {{floor|-0.9999999999999998334665463062265}} || {{ceil|-0.9999999999999998334665463062265}}
|-
| -0.999999999999998334665463062266 || {{floor|-0.9999999999999998334665463062266}} || {{ceil|-0.9999999999999998334665463062266}}
|-
| -0.999999999999998334665463062267 || {{floor|-0.9999999999999998334665463062267}} || {{ceil|-0.9999999999999998334665463062267}}
|-
| -0.999999999999999444888487687420 || {{floor|-0.9999999999999999444888487687420}} || {{ceil|-0.9999999999999999444888487687420}}
|-
| -0.999999999999999444888487687421 || {{floor|-0.9999999999999999444888487687421}} || {{ceil|-0.9999999999999999444888487687421}}
|-
| -0.999999999999999444888487687422 || {{floor|-0.9999999999999999444888487687422}} || {{ceil|-0.9999999999999999444888487687422}}
|-
| 0.(322)01 || {{floor|-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001}} || {{ceil|-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001}}
|-
| 0.(323)01 || {{floor|-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001}} || {{ceil|-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001}}
|}
 
; See also<nowiki>:</nowiki>
* [[Template:Ceil]]
 
[[Category:Templates using ParserFunctions|{{PAGENAME}}]]
[[Category:Mathematical templates|{{PAGENAME}}]]
 
[[fr:Modèle:Floor]]
[[nl:Sjabloon:Floor]]
</noinclude>

Latest revision as of 13:19, 3 September 2020

⌊{{{1}}}⌋