Difference between revisions of "Template:SI prefix"

From Kerbal Space Program Wiki
Jump to: navigation, search
m (!shifted k,M,G,T;)
m (+sort key;)
 
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 23: Line 23:
 
|12 = {{#expr: {{{1}}}/1000000000000 round {{{2|2}}}}}&nbsp;{{Dict|T}}
 
|12 = {{#expr: {{{1}}}/1000000000000 round {{{2|2}}}}}&nbsp;{{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