# Calculate range value from given percent

I have a slider than returns percent from 0-1. So I have:

min:0.5
max:3
percent:0.5


I want to retrive what value from range this percent gives (in steps of 0.1). So half from 0.5-3 would be roughly 1.2 (or 1.3 if I round up). How would I calculate this? min can also be positive.

There are 35 steps in increments of 0.1 from 0.5 to 3.0 (0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2 etc... 2.9, 3.0) , so 50% for example would be on the half of that.

• $\min + (\max - \min)*\text{percent}$ Dec 23, 2019 at 20:09
• This is what I wanted. Dec 24, 2019 at 0:06

Assuming you want to compute $$p$$ percent value $$v$$ between min $$m$$ and max $$M$$, where $$M > m$$ and $$0 \le p \le 1$$, you compute $$v = m + p(M-m) = pM + (1-p)m.$$
For your example, $$m = 0.5, M = 3$$ and $$p = 50\% = 0.5$$ so we get $$v = 0.5 + 0.5(3-0.5) = 0.5+1.25=1.75,$$ which is exactly half-way between $$M=3$$ and $$m = 0.5$$, as expected.
value = percent * (max - min) + min

which in the above case would give $$value = 0.5 \times (3 - 0.5) + 0.5 = 1.75$$, that is half-way from the min to the max.