I'm trying to figure out the calculation for finding the percentage between two values that a third value is.
Example: The range is 46 to 195 m3h. The value 46 would 0%, and the value 195 would be 100% of the range. What percentage of this range is the value 65?
rangeMin=46
rangeMax=195
inputValue=65
inputPercentage = ?
Usage of this is i have calculated three Vav. And then i need the sum of these to give me back a procent value to give the regulator.Example: The range is 46 to 195 m3h. The value 46 would 0%, and the value 195 would be 100% of the range. What percentage of this range is the value 65?
rangeMin=46
rangeMax=195
inputValue=65
inputPercentage = ?
Found this code on different site. But i think that this is missing something
Code:
function rangePercentage (input, range_min, range_max, range_2ndMax){
var percentage = ((input - range_min) * 100) / (range_max - range_min);
if (percentage > 100) {
if (typeof range_2ndMax !== 'undefined'){
percentage = ((range_2ndMax - input) * 100) / (range_2ndMax - range_max);
if (percentage < 0) {
percentage = 0;
}
} else {
percentage = 100;
}
} else if (percentage < 0){
percentage = 0;
}
return percentage;
}