Finding the percentage between two values

To find a percentage of a certain value between range (ex. Min=23 & Max=95) then use the formula below.

z = ((n - min) * 100) / (max - min)

Let n = input value, z = is the % of that value between min and max.

We will use JavaScript to apply the formula.

function percent_from_range(min, max, input) {
   var percent_of_input = ((input - min)*100) / (max -min);
   return Math.round(percent_of_input);
}

var percent = percent_from_range(23, 95, 45);

/* the result is 31% */

You can validate the formula using this link @jsfiddle.net

Math Math Formula Percentage