User:Σ/Testing facility/Rangemap/doc

Usage
or, without specifying argument names:

Description
Re-maps a number from one range to another. That is, a value of from_low would get mapped to to_low, a value of from_high to to_high, values in-between to values in-between, etc.

Does not constrain values to within the range, because out-of-range values are sometimes intended and useful.

Note that the "lower bounds" of either range may be larger or smaller than the "upper bounds" so this template may be used to reverse a range of numbers, for example

The template also handles negative numbers well, so that this example

{{rangemap|{{{x}}}|1|50|50|-100)

is also valid and works well.

Appendix
For the mathematically inclined, here's the expression: (value - from_low) * (from_high - from_low) / (to_high - to_low) + to_low