f(x)=Round(x−ab−a⋅(N−1)) f−1(n)≈a+nN−1⋅(b−a)\begin{align*} &\text{ }\: f(x) = \text{Round}\left( \frac{x - a}{b - a} \cdot (N - 1) \right) \\ &\text{ }\: f^{-1}(n) \approx a + \frac{n}{N - 1} \cdot (b - a) \end{align*}