How to do Feature Scaling for these ranges [0,1] and [-1,1]?

I want to rescale the features of my data to be between [0,1] and [-1,1]? Is their a clear cut way that works every time for these ranges? I think the below equation works for [0,1] but when it is describe people say generally it works, so I am not certain it works every single time.

To normalize in $[-1,1]$ you can use:
$$x'' = 2\frac{x - \min{x}}{\max{x} - \min{x}} - 1$$
In general, you can always get a new variable $x'''$ in $[a,b]$:
$$x''' = (b-a)\frac{x - \min{x}}{\max{x} - \min{x}} + a$$