Floating occurs because floating objects displace, or push aside, a certain amount of liquid. If an object displaces more than its weight in liquid, it floats; otherwise it sinks.
Density (the mass per unit of volume) determines how much liquid is displaced. Density is usually compared to water, which is assigned a density of 1. Materials sink if (like regular Coke) they are more dense than water, while less-dense materials, like Diet Coke, float.
Actual photograph of the experiment as performed in the Why Files lab! Note the Diet Coke breaking the surface on the left.
We didn't ask the Coca Cola Co. for their recipe, but we assume that it's the sugar in real Coke that makes it dense enough to sink. We also assume that it's the artificial sweetener in that diet version that's less dense, allowing those cans to float.
http://whyfiles.org/071questions/5.html