TITLE: Shift numbers into a different range
QUESTION [21 upvotes]: I was wondering how can I shift my data that fall between a range lets say [0, 125] to another range like [-128, 128].
Thanks for any help

REPLY [3 votes]: To map [a,b] onto [c,d], just seek the equation of the line through the points (a,c) and (b,d). A point M(x,y) will lie on this line iff det(AM, AB)=0. i.e., (x-a)(d-c)=(y-c)(b-a). Then proceed to solve this equation for y in terms of x. Straightforward algebra yields y = c + ((d-c)/(b-a))(x-a). It is therefore very easy to see that, indeed, a is mapped onto c, b to d and anything in between a and b onto something in [c,d].