Template:Convert/scale

From WikiSwire
Jump to navigation Jump to search

2+34 {{{2}}} (5.50 {{{3}}})


The Template:Convert/scale allows a custom scale formula to be used to convert a unit into
another unit. The general conversion formula is:  y = a·x + b   or   y = a·(x+offset) + b.

Usage:  {{convert/scale|3.5|ins|outs|a=2|b=1}} → 3.5 ins (8.00 outs)
{{convert/scale|10.0|www|zzz|a=6.70|b=0.5}} → 10.0 www (67.50 zzz)
{{convert/scale|12.0|[[erg]]s|korts|a=3.85|offset=-2|b=0.4}} → 12.0 ergs (38.90 korts)

The formula has x as the number from parameter 1, where the scale factor is a (default a=2.0), the
original offset amount is parameter offset=0.0, and the final shift is parameter b=0.0 (or add=0.0).

The parameters are:

{{{1}}}  - the amount to convert (can have a fraction: 2+3/4)
{{{2}}}  - the literal input unit name or symbol
{{{3}}}  - the literal output unit name or symbol
a (or f) - the scale factor (default: a=2.0)
offset   - the initial offset amount (default: offset=0.0)
b (or add) - the final shift amount (default: add=0.0)
r         - the rounding amount (default: same precision as {1} )
sep     - separator text between input unit & output amount (default: "( )" parentheses)

The basic formula is a linear conversion, scaling the amount from parameter 1.