

An eggshell has tiny pores. As an egg ages, water leaves and air enters, so the air pocket at the blunt end grows and the egg gets lighter. A floating egg is old. That is a freshness test, not a safety test. An egg can be fresh and carry Salmonella, and an old egg can be harmless. Safety comes from cold storage and from cooking the egg until the white and yolk are firm.
Do not use eggs with cracked shells. A crack lets bacteria in. If an egg cracks at home, crack it into a clean container, cook it at once, or bin it.