I have a float number which represent percentage (0.0 to 100.0) %
float represent = 50.00; // fifty present, or half.
as an example: convert this number to a range from -2 to 2
thus:
represent=0 will be represented as -2
represent=50 will be represented as 0
represent=100 will be represented as 2
EDIT:
good simple answer from Orbling and friends, Still I am looking for something along the lines of : map(value, fromLow, fromHigh, toLow, toHigh)
Is there a function in objective C to map such range for more complex values?
This should do the trick:
Explanation:
Example usage: