I have the following function to convert this function to percentage. The range of $y$ is $-120$ to $0$, so $-120 = 0\%$ and $0 = 100\%$.
$$percentage = 10^{(y + 160) / 80}$$
How do I go the other way by converting a percentage to the range $-120$ to $0$?
This doesn't quite work
$$y = 80 * log_{10}(percentage) - 160$$
Code to convert range $(-120, 0)$ to percentage
if (y > -120) {
n = Math.pow(10, ((y + 160) / 80));
if (n > 100) {
n = 100;
}
if (n < 0) {
n = 0;
}
}
Thanks in advance
BT