Why don't objects bounce infinitely? I'm computer programmer, and I was making a little test of my “possibilities”, so to speak, so I made a small game with sort of gravity, bouncing ball and walls around.
Recently I've noticed that when bouncing off a wall, the ball will divide its speed and so endlessly even if the speed is less than 1 (digital pixels per second), for example if speed equals to 0.05 pixels per second it will divide and it will be 0.025 pixels per second, etc. To prevent this, I did limit bounce values.
How can this be explained in real life physics? Are there any limits of bounce value?
 A: Suppose the ball loses a fraction $b$ of its velocity on every bounce. Let's also assume the ideal case, where the ball takes an infinite amount of bounces to lose all of its momentum. (In reality, the model is no longer valid at sufficiently small bounces, because, for example, thermal fluctuations of the atoms in the materials are larger.) The key here is that, while there are an infinite number of bounces, they happen in a finite amount of time, and we can actually calculate that time.
Let's start with the ball in the air at height $h$, at rest (i.e. right when it's dropped). The amount of time $t_0$ it takes to fall a distance $h$ is given by the usual kinematic equations:
$$t_0=\sqrt{\frac{2h}{g}}$$
When it reaches the ground, it has a velocity $v_0=gt_0=\sqrt{2gh}$. After the bounce, it has a velocity $v_1=(1-b)\sqrt{2gh}$, since it lost a fraction $b$ of its velocity. The time it takes to go to the next bounce $t_1$ is equal to the time it takes for the velocity to change from $v_1$ to $-v_1$; in other words, 
$$gt_1=2v_1\implies t_1=2(1-b)\sqrt{\frac{2h}{g}}$$
On the second bounce, it has a velocity $v_2=(1-b)v_1=(1-b)^2\sqrt{2gh}$, and we can repeat the same procedure forever.
So, in general, for bounce $n$, we have that $v_n=(1-b)^n\sqrt{2gh}$, and therefore that
$$t_n=2(1-b)^n\sqrt{\frac{2h}{g}}$$
The time $t_{rest}$ it takes for the ball to come to rest is equal to the time it takes to complete all of the bounces (since this is a geometric series, we can actually evaluate it exactly):
\begin{align}
t_{rest}&=t_0+\sum_{n=1}^\infty t_n\\
&=\sqrt{\frac{2h}{g}}+\sum_{n=1}^\infty\sqrt{\frac{8h}{g}}(1-b)^n\\
&=\sqrt{\frac{2h}{g}}+\sqrt{\frac{8h}{g}}\frac{1}{b}-\sqrt{\frac{8h}{g}}\\
&=\frac{1}{b}\sqrt{\frac{8h}{g}}-\sqrt{\frac{2h}{g}}
\end{align}
For example, for a ball with $b=0.1$ dropped from height of 1 meter will execute an infinite number of bounces and come to rest after roughly 8.6 seconds according to this model. If instead that ball had $b=0.4$, it would come to rest in roughly 1.8 seconds. So if you're not worried about the number of bounces, then this is a perfectly workable solution for how much time it takes for a bouncing ball to come to rest.

That said, if you're doing a simulation, you're likely worried about an infinite number of bounces as well. In that case, one thing you can do is take advantage of the fact that your simulation (probably) has a finite time step. You can calculate $t_n$ with the above, and whenever $t_n$ is shorter than your time step, the object stops bouncing.
