in reply to Normalizing a range of numbers to a percentage
my $x = (($tap - $min) * ($new_max - $new_min) / ($max - $min)) + $new +_min;
In your case $new_min was zero, so your numbers are good.
I think of it this way:
is the ratio on the old scale, then multiply by the new scale and add the new offset.($tap - $min) / ($max - $min)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Normalizing a range of numbers to a percentage
by stevieb (Canon) on Mar 07, 2019 at 23:19 UTC | |
by pryrt (Abbot) on Mar 07, 2019 at 23:23 UTC | |
by stevieb (Canon) on Mar 07, 2019 at 23:30 UTC | |
by tybalt89 (Monsignor) on Mar 07, 2019 at 23:36 UTC | |
by pryrt (Abbot) on Mar 08, 2019 at 00:41 UTC | |
| |
|
Re^2: Normalizing a range of numbers to a percentage
by pryrt (Abbot) on Mar 07, 2019 at 23:16 UTC | |
by tybalt89 (Monsignor) on Mar 07, 2019 at 23:41 UTC |