Math help needed

for the following:

I’ve built a slider which also contains an input textfield. the slider can be dragged and it’s value will be updated in the textfield. a user can also enter a value in the textfield which will then be reflected in the slider.

All is fine thusfar. However, I’d like to figure out how to give the slider an exponential scale instead of a linear one.

Say the slider has a minimum value of 0 and a max of 100. When the slider is dragged halfway then using a linear scale it’s value would ofcourse be 0.5 * 100 = 50.

To calculate the value for the exponential scale I use

Math.pow(max - min, ratio)

where halfway down the slider the ratio is ofcourse 0.5

Now, what about when I want to do it the other way around: calculate the ratio based upon a value entered in the textfield?

I hope I made myself clear :slight_smile: