A similar definition applies to molecules; it is then called molecular mass. It turns out that one can compute the molecular mass of a compound by adding the atomic masses of its constituent atoms, counted with the proper multiplicities. This technique misses only the chemical binding energy, which is usually negligible.
Various experiments allow to compare masses of atoms or molecules, and atomic and molecular weights can therefore be determined rather easily.
One mole of a substance always weighs exactly the atomic or molecular weight of that substance, expressed in grams. For example, the atomic weight of iron is 55.847, and therefore one mole of iron atoms weighs 55.847 grams.
Formerly chemists and physicists used two different atomic weight scales. The chemists used a scale such that the natural mixture of oxygen isotopes had an atomic weight 16, while the physicists assigned the same number 16 to the atomic weight of the most common oxygen isotope (containing eight protons and eight neutrons). The unified scale based on C12 met the physicists' need to base the scale on a pure isotope, while being numerically close to the old chemists' scale.