Search code examples
mathlanguage-agnostic

Math - Percentage to Range Conversion


I'm trying to solve a problem where I know a percentage (set by the user) but I need to find where that percentage is on a range of numbers, so for instance if the user sets it to 50% and the value range is -10 to 10 the value would be 0.

It seems simple in my head but I'm tripping up on this one.


Solution

  • This should work

    pos = low + (high - low) * percentage