Difference between revisions of "Template:SI prefix"
From Kerbal Space Program Wiki
(Created page with "<includeonly>{{#switch: {{#ifexpr: {{{1}}}<1e-9|-9|{{#ifexpr: {{{1}}}>1e12|12|{{#expr: floor(ln {{{1}}}/ln 10)}}}}}} |-9 |-8 |-7 = {{#expr: {{{1}}}*1000000000 round {{{2|2}}}}...") |
m (+sort key;) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <includeonly>{{#switch: {{#ifexpr: {{{1}}}<1e-9|-9|{{#ifexpr: {{{1}}}>1e12|12|{{#expr: floor(ln {{{1}}}/ln 10)}}}}}} | + | <includeonly>{{#ifeq: {{lc:{{{sort|n}}}|y}}|data-sort-value="{{{1}}}" {{!}} }}{{#switch: {{#ifexpr: {{{1}}}<1e-9|-9|{{#ifexpr: {{{1}}}>1e12|12|{{#expr: floor(ln {{{1}}}/ln 10)}}}}}} |
|-9 | |-9 | ||
|-8 | |-8 | ||
Line 9: | Line 9: | ||
|-2 = {{#expr: {{{1}}}*100 round {{{2|2}}}}} {{Dict|c}} | |-2 = {{#expr: {{{1}}}*100 round {{{2|2}}}}} {{Dict|c}} | ||
|-1 = {{#expr: {{{1}}}*10 round {{{2|2}}}}} {{Dict|d}} | |-1 = {{#expr: {{{1}}}*10 round {{{2|2}}}}} {{Dict|d}} | ||
− | | 0 | + | | 0 |
| 1 | | 1 | ||
− | | 2 | + | | 2 = {{#expr: {{{1}}} round {{{2|2}}}}} |
− | + | | 3 | |
| 4 | | 4 | ||
− | | 5 | + | | 5 = {{#expr: {{{1}}}/1000 round {{{2|2}}}}} {{Dict|k}} |
− | + | | 6 | |
| 7 | | 7 | ||
− | | 8 | + | | 8 = {{#expr: {{{1}}}/1000000 round {{{2|2}}}}} {{Dict|M}} |
− | + | | 9 | |
|10 | |10 | ||
− | |11 | + | |11 = {{#expr: {{{1}}}/1000000000 round {{{2|2}}}}} {{Dict|G}} |
|12 = {{#expr: {{{1}}}/1000000000000 round {{{2|2}}}}} {{Dict|T}} | |12 = {{#expr: {{{1}}}/1000000000000 round {{{2|2}}}}} {{Dict|T}} | ||
}}</includeonly><noinclude>Returns the value with the corresponding SI prefix. Only the unit needs to be added. Supports the prefixes from <tt>nano</tt> (10⁻⁹) to <tt>tera</tt> (10⁺¹²), except deca (10¹) and hecto (10²). It round to the number of places given in the second parameter which defaults to 2. | }}</includeonly><noinclude>Returns the value with the corresponding SI prefix. Only the unit needs to be added. Supports the prefixes from <tt>nano</tt> (10⁻⁹) to <tt>tera</tt> (10⁺¹²), except deca (10¹) and hecto (10²). It round to the number of places given in the second parameter which defaults to 2. | ||
+ | |||
+ | {{Parameter table|name=both|parameters= | ||
+ | {{Parameter row|1|Value in base unit (e.g. meters, kilograms)}} | ||
+ | {{Parameter row|2|Number of decimal places to be round to.|<tt>2</tt>}} | ||
+ | {{Parameter row|sort|If set to 'y' (or 'Y') it automatically adds the value as a sort key.|<tt>n</tt>}} | ||
+ | }} | ||
[[Category:Calculating templates]]</noinclude> | [[Category:Calculating templates]]</noinclude> |
Latest revision as of 14:17, 28 September 2014
Returns the value with the corresponding SI prefix. Only the unit needs to be added. Supports the prefixes from nano (10⁻⁹) to tera (10⁺¹²), except deca (10¹) and hecto (10²). It round to the number of places given in the second parameter which defaults to 2.
#/Name | Optional | Description | Default |
---|---|---|---|
1 | No | Value in base unit (e.g. meters, kilograms) | |
2 | Yes | Number of decimal places to be round to. | 2 |
sort | Yes | If set to 'y' (or 'Y') it automatically adds the value as a sort key. | n |