How to invert a range

Issue

I have a range of values from 0 to 100, and I want to have the values inverted (ex. 100->0,0->100, 25->75, etc)
How would I do this? (in any language)

Solution

For each value, do 100 - value.

Note:
A general function for a range (min, max) would be:

invert(min, max, value)
  => max - value + min;

Answered By – SymboLinker

Answer Checked By – David Goodson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.