I think it would be more efficient to just create a lookup table which maps PWM values to Range Values, you can do all the pre-calculations in Excel or something.
just create a static const array, it will be stored in read only memory so you don't have to worry too much about the size of the array
Code:
static const int lookup = { 1,2,3....4};
where 1,2,3,4 are your range values
now say you only have a pwm range from 90-150 (61 different values)
lookup[60] would be the range value for pwm 150, so for the look up function you could do something like this:
Code:
int getRange(int pwm)
{
if(pwm<90) {println("ERROR : unexpected lookup value!"); return -1;}
return lookup[pwm-90];
}
I'd advise against using a double or a float for storing range in an array
because you really don't need
that much precision (if the range is in inches) and it would just be a waste of memory