this is similar to a previous question so I've pasted the original question here with my amendment.

"I have a slider that returns a value in a given range, so:

min: 174 max: 424 slider current value: 230 I want to treat my min value as 0% and my max value as 100%. What formula can I use to calculate the percentage for my slider in this given range?"

My problem is that the minimum value is negative. (MACD for those who are wondering). For example the Max could be 0.078 and the minimum -0.094. I'm not sure if this affects how it should be calculated... Hence why I'm here...


To calculate percentages, we need a zero based range.

In the other question, there were positive values, minimum 174 and maximum 424.

The values were shifted by -174 to achieve the zero-based range.

This is your case, when the values can be both negative and positive:

Minimum value: -0.094

Maximum value: 0.078

How can we calculate a percentages in that range then? Well, we can shift the numbers to the zero-based range by adding the opposite number of the initial minimum value to all figures. Min and max would then be:

Minimum value: -0.094+0.094 = 0

Maximum value: 0.078+0.094 = 0.172

Now we have the zero based range which we can use to calculate percentages normally. Just remember to add 0.094 to your value in the range to calculate the percentage from, too.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.