How to get maximum number 500 out of one variable Im designing a website and I need to make a sum which will allow the result to be a maximum of 500. So the variable can be anything from '0' to 'a billion' and second number is 12. So just by basic math I would like to always get either 500 or less and never more than 500. Can this be done by basic math? 
Example variable x/x * 500 will always give 500 (without 12), so that is wrong.
 A: Well, there are tons and tons of functions that never go higher than 500. One of them is $f(x) = \min (x, 500)$ (in Javascript, Math.min(x, 500)). This function simply gives you either $x$ or 500, whichever is smaller.
We might be able to "build" a function that behaves more nicely. The function $e^x$ is never less than 0, which means that $-e^x$ is never more than 0, which means that $500 - e^x$ is never more than 500. But if you look at a graph of this function, you'll see that as $x$ gets larger, $500 - e^x$ gets smaller.
We can make things go the other way around, though. We know that as $x$ gets larger, $-x$ gets smaller, and that as $-x$ gets smaller, $500 - e^{-x}$ gets larger. So, as $x$ gets larger, $500 - e^{-x}$ gets larger. Here's a graph of this function. In Javascript, that function is 500 - Math.exp(-x).
The thing is, if $x = 0$, then $500 - e^{-x} = 499$, so this function doesn't do a great job of leaving small values of $x$ alone. After a bit of experimenting, I've come up with the function $f(x) = 500 (1 - e^{-x/500})$ (in Javascript, 500 * (1 - Math.exp(-x/500))). For small values of $x$, $f(x)$ is approximately $x$, but for large values of $x$, $f(x)$ is approximately 500.
A: How about $$ f(x) = \frac{x + 12}{10^9 + 12} \cdot 500? $$ ($10^9$ is a billion).  Am I understanding you correctly? 
