Going back to an answer to the original question, the reason the egg floats when it's bad is because it has air/gas in it that makes it float. The reason for the air/gas inside it is because it has bacteria of some kind growing in it. They grow and multiply, and they use the insides of the egg as their food source. Their growth produces the gases inside the egg. It's like when the milk goes bad and you didn't open it for a while and when you do open it, there is a little "poof" when you open the lid - that's the gases produced by the bacteria growing in it. So that is why the egg floats.
Also, just as the egg gets older, because the shell can be porous (especially if washed) then there can be some air exchange into the egg and the insides begin to desiccate a little bit (dry out slightly) which makes the air space bigger.
And finally, you asked how do I know this? Well, I know about the "floating egg" test because my mom taught it to me when I was a little girl. The rest of the stuff above I know because I have a lot of science education including a masters in molecular biology, so I have studied a LOT about bacteria! And I grew a lot of them in the laboratory! Ewwww.... LOL!