When an egg floats, it's because a small air pocket inside the shell has had enough time to expand sufficiently to make the egg buoyant. Floating can be a sign an egg isn't as fresh as you might want it to be, but it takes closer inspection to determine whether the egg is spoiled. It all depends on time and the eggshell.
Eggshells look solid, but in reality they're rather porous. After a hen lays an egg, fluid evaporates through microscopic holes in the shell and air seeps in as the egg cools. The air collects in a pocket at one end. As the egg ages and takes in more air, this air pocket expands and eventually gives the egg enough buoyancy to float in water.
Dunking for Freshness
Placing eggs in water to test their freshness is an old technique. Using a spoon, you lower the eggs into a bowl or pan of cold, unsalted water. The freshest eggs will sit on the bottom of the container. Some eggs will tilt upward, indicating they have more air inside and are older. Other eggs will stand up on the point end; these eggs usually are still safe but are better used to make hard-cooked eggs or in baking.
The Nose Knows Rotten Eggs
Eggs that float to the top are often considered spoiled because more air has seeped in through the shell and decomposition may have started. Decomposition, or spoiling, produces sulfur gas, the cause of the "rotten egg" smell. There's only one sure way to tell if an egg that floats is spoiled, and that's to crack it open in a bowl. If it smells bad and looks discolored, throw it out. If it looks and smells fresh, you can use it for cooking or baking.
Take Extra Care with Eggs
Eggs need careful handling and storage because their shells can harbor salmonella bacteria. More than 2,300 different varieties of salmonella can exist on eggshells. Because low temperatures inhibit salmonella growth, the USDA and the American Egg Board both recommend eggs in their cartons be refrigerated at temperatures between 33 and 40 degrees Fahrenheit. This keeps them outside the "danger zone" between 40 and 140 F, where bacteria grow fastest. Eggs left out at room temperature should be discarded after two hours, or after one hour if the room is especially warm.