మూస:Convert/scale
2 3⁄4 {{{2}}} (మూస:Rndpad {{{3}}})
{{Convert/scale}} allows a custom scale formula to be used to convert a unit into another unit. The formula used is:
- output = round(a × ({{{1}}} + offset) + b, r)
That is, output is calculated by adding parameters {{{1}}} and offset, multiplying the result by parameter a, adding parameter b, then rounding according to parameter r.
Usage
[మార్చు]The format is:
- {{convert/scale|10.0|ww|zz|a=6.7|b=0.4|r=3}} → 10.0 ww (67.400 zz)
- {{convert/scale|4|m|ft|scale=3.28|add=0}} → 4 m (13.1 ft)
Synonyms for parameter a are f or scale. A synonym for parameter b is add.
The output of the template is the following space-separated group of values:
- {{{1}}} {{{2}}} (output {{{3}}})
Non-breaking spaces are the default between values and units, but can be reset by using a leading space or " " or "-" prefix before words.
If parameter sep is present, it replaces the opening parenthesis and there is no closing parenthesis.
The parameters are:
Param | Description |
---|---|
1 | Amount to convert (can have a fraction, default: 2+3/4) |
2 | Literal input unit name or symbol (can have prefix "-" or space) |
3 | Literal output unit name or symbol (or prefix "-" or space) |
a or f or scale |
Scale factor (default: 2.0), to divide by 4, use a=(1/4) |
offset | Initial offset amount (default: 0.0) |
b or add | Final shift amount (default: 0.0) |
r | Number of decimal places in the result. Negative numbers round to nearest multiple of powers of 10 (i.e. -3 rounds to the nearest thousand). i.e., rounding is to the nearest multiple of 10−r. The default value of r is the precision of parameter 1, plus 1. |
sep | Separator text between input unit & output amount (default: "( )" parentheses) |
Examples:
Wikitext | Result |
---|---|
{{Convert/scale |3.5 |ins |outs |a=2 |b=1}} | 3.5 ins (మూస:Rndpad outs) |
{{Convert/scale |10.0 |www |zzz |a=6.70 |b=0.5}} | 10.0 www (మూస:Rndpad zzz) |
{{Convert/scale |12.0 |[[erg]]s |korts |a=3.85 |offset=-2 |b=0.4}} | 12.0ergs (మూస:Rndpad korts) |
{{Convert/scale |1.2 |million m<sup>2</sup> |million ft<sup>2</sup> |a=10.764 |r=0}} | 1.2 million m2 (మూస:Rndpad million ft2) |
{{convert/scale |2|-foot|m|a=(1/3.28) }} | 2-foot (మూస:Rndpad m) |
{{convert/scale |345| kilometres| miles|a=1.6093}} | 345 kilometres (మూస:Rndpad miles) |
{{convert/scale |80| miles|km|a=(1/1.6093) }} | 80 miles (మూస:Rndpad km) |