Difference between revisions of "Template:Infobox road/meta/length/sandbox"

From blackwiki
Jump to navigation Jump to search
imported>WOSlinker
(last edit no longer needed)
imported>Wikid77
(changed to round the result by simple {#expr: ...round...} rather than Template:Rnd which can add trailing zeroes; put typical doc-text to explain template operation.)
Line 1: Line 1:
<includeonly>{{#ifexpr:{{{length}}}>=1000|{{formatnum:{{{length}}}}}|{{{length}}}}} {{{1}}}{{#if:{{{length_ref|}}}|{{{length_ref}}}|}} ({{rnd|{{#expr:{{{length}}} * {{#ifeq:{{{1}}}|mi|1.609344|0.621371192}}}}|{{#if:{{{round|}}}|{{{round}}}|{{Getprecision|{{{length}}}}}}}}} {{#ifeq:{{{1}}}|mi|km|mi}})</includeonly>
+
{{#ifexpr:{{{length|567.3}}}>=1000|{{formatnum:{{{length|567.3}}}}}|{{{length|567.3}}}}} {{{1|mi}}}{{#if:{{{length_ref|}}}|{{{length_ref}}}|}} (<!--
 +
-->{{#expr:{{{length|567.3}}} * {{#ifeq:{{{1|mi}}}|mi|1.609344|0.621371192}} round {{#if:{{{round|}}}|{{{round}}}|{{precision|{{{length|567.3}}}|}} }} }} {{#ifeq:{{{1|mi}}}|mi|km|mi}})<noinclude>
 +
 
 +
The '''[[Template:Infobox_road/meta/length]]''' converts miles to [[kilometre]]s, or the reverse, where parameter 1 is "mi" or "km" and the distance is length=567.3 or such.
 +
 
 +
The template rounds the result to the precision of the input decimal digits, where, for example, {&#123;precision|234.65}} is {{precision|234.65}}, for 2 decimal digits. The template expansion depth is 6 levels, of the 41-level limit.
 +
 
 +
[[Category:Infobox road]]
 +
</noinclude>

Revision as of 04:41, 8 September 2012

567.3 mi (Expression error: Unrecognized punctuation character "[". km)

The Template:Infobox_road/meta/length converts miles to kilometres, or the reverse, where parameter 1 is "mi" or "km" and the distance is length=567.3 or such.

The template rounds the result to the precision of the input decimal digits, where, for example, {{precision|234.65}} is Template:Precision, for 2 decimal digits. The template expansion depth is 6 levels, of the 41-level limit.