Template:Floor: Difference between revisions
From Zoophilia Wiki
Jump to navigationJump to search
meta>Verdy p mNo edit summary |
meta>Upssdr~enwiki No edit summary |
||
Line 34: | Line 34: | ||
* <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 substracting 0.5 yields -1.5 exactly due to precision limits, which then rounds to -2). | * <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 substracting 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). | * <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}} | |||
|} | |||
; See also<nowiki>:</nowiki> | ; See also<nowiki>:</nowiki> |
Revision as of 04:50, 4 May 2006
Template:Template documentation 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.
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.
- Usage:
- {{Floor|value}}
- Examples:
- {{Floor|3.9}} = 3.
- {{Floor|3.5}} = 3.
- {{Floor|3.1}} = 3.
- {{Floor|3.0}} = 3.
- {{Floor|1.0}} = 1.
- {{Floor|0.9}} = 0.
- {{Floor|0.5}} = 0.
- {{Floor|0.1}} = 0.
- {{Floor|0.0}} = 0.
- {{Floor|-0.1}} = -1.
- {{Floor|-0.5}} = -1.
- {{Floor|-0.9}} = -1.
- {{Floor|-1.0}} = -1.
- {{Floor|-3.0}} = -3.
- {{Floor|-3.2}} = -4.
- {{Floor|-3.5}} = -4.
- {{Floor|-3.9}} = -4.
- Known bug (should appear extremely rarely as this goes beyond the precision of math performed in pages using this template)
- {{Floor|0.99999999999999983}} = 1 (OK).
- {{Floor|0.99999999999999984}} = 1 (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 substracting 1 gives 1 exactly).
- {{Floor|0.99999999999999999}} = 1 (wrong but comes from limited floating point precision, the input is considered equal to the exact integer 1).
- {{Floor|-0.99999999999999983}} = -2 (OK).
- {{Floor|-0.99999999999999984}} = -2 (wrong but comes from limited floating point precision, the input is not exactly equal to the integer -1, but substracting 0.5 yields -1.5 exactly due to precision limits, which then rounds to -2).
- {{Floor|-0.99999999999999999}} = -1 (OK, the input is considered equal to the exact integer -1, so this exact -1 integer is returned).
num | floor | ceil |
---|---|---|
-0.999999999999998334665463062265 | -2 | ⌈-0.9999999999999998334665463062265⌉ |
-0.999999999999998334665463062266 | -2 | ⌈-0.9999999999999998334665463062266⌉ |
-0.999999999999998334665463062267 | -2 | ⌈-0.9999999999999998334665463062267⌉ |
-0.999999999999999444888487687420 | -2 | ⌈-0.9999999999999999444888487687420⌉ |
-0.999999999999999444888487687421 | -2 | ⌈-0.9999999999999999444888487687421⌉ |
-0.999999999999999444888487687422 | -1 | ⌈-0.9999999999999999444888487687422⌉ |
- See also: