User:Wikid77/Template:Convert/f
9,503.1 metres (31,168 ft*)
The converter Template:Convert/f will convert an amount and display the amount with special formatting. To set the rounding precision, the output unit must be specified, or put "0" to default.
- Usage: {{convert/f |100.51432|m|ft|r1=1}}
- {{convert/f |1,234|km|mi|comma=off}}
- {{convert/f |10.5|L|usgal|3|x3=exactly}}
- {{convert/f |7|km|mi|disp=x|long (|)}} - custom output
There are special options with Convert/f, such as r1=2 to round the input amount to 2 decimals, comma=out to show commas only in the output amount, near=25 (or 50) to round to nearest 25, and "x0=zz" to "x5=zz" to insert text before/after the unit names.
12,340 kilometres (7,670 miles) | | | | | | x0 x1 x2 x3 x4 x5
While parameters x0 and x1 insert text before or after the first amount, x2 follows the input unit, x3 puts text before the output amount, x4 follows the output, and x5 follows the output unit name.
The template allows the same parameters as Template:Convert, and so it allows abbreviation abbr=in or abbr=out or abbr=off, wikilinks lk=in or lk=out, and adjective mode adj=on or adj=mid. The separator can also be a semicolon: disp=semi, disp=or, disp=comma, disp=x (customized), disp=sqbr (square brackets), disp=b (default as parentheses), disp=2 (or disp=out) and disp=# (or disp=number).
Examples
[edit]The examples show various options of conversions:
- {{convert/f |1,234|km|mi|comma=off}} → 1234 kilometres (767 mi*)
- {{convert/f |950|km|mi|abbr=~}} → 950 kilometres (km, 590 mi*)
- {{convert/f |3.1415926|km|mi|r1=2}} → 3.14 kilometres (1.9520951 mi*)
- {{convert/f |9,564|km|mi|comma=out}} → 9564 kilometres (5,943 mi*)
- {{convert/f |9,564|km|mi|lk=in|near=5}} → 9,564 kilometres (5,945 mi*)
- {{convert/f |9,564|km|mi|lk=out|near=50}} → 9,564 kilometres (5,950 mi*)
- {{convert/f |10.5|L|usgal|4|x3=exactly}} → 10.5 litres (exactly 2.7738 US gal*)
- {{convert/f |10.5|L|x3=nearly}} → 10.5 litres (nearly 2 imp gal; 3 US gal*)
- {{convert/f |10.5|L|x1=<b>|x2=</b>}} → 10.5 litres (2 imp gal; 3 US gal*)
Display types: disp=comma, disp=semi, disp=or, disp=out, disp=number, disp=x and disp=b. The numeric results are identical to using Template:Convert to show a conversion.
The multi-unit outputs, such as for litres ("L") to both impgal and usgal, cannot handle near=n, so use Template:Convert/show2 (or Template:Convert/show3) to show multiple outputs rounded by near=n.
Common problems
[edit]Note the name of this template is "convert/f" and omitting the suffix "/f" will not show special formatting. Also, putting "f" as parameter 1 will cause the number to be treated as a template name "Convert/<number>" such as {{convert|f|34|km}} will show "[convert: invalid number]".
The amount is followed by a unit-code (such as "|m") as the 2nd parameter. The output unit-code can be "0" as the 3rd parameter, to allow the default output unit to be triggered, while setting parameter 4 to a rounding precision (such as "|5") or use r=5 to set the rounding level.
See also
[edit]- Template:Convert/per
- Template:Convert/2 - convert a range of 2 amounts, with any separator
- Template:Convert/3 - convert 3 amounts, with any separators
- Template:Convert/4 - convert 4 amounts, with any separators
- Template:Convert/show2 - convert an amount to any 2 output units
- Template:Convert/show3 - convert an amount to any 3 output units