Good observation! This is a really important question with three contributions.
Most periodic tables give the masses of atoms in "Atomic Mass
Units", or AMU. One AMU is 1/12th the mass of a Carbon-12 atom. But the
masses listed (at least in the periodic table on my bookshelf) are not
for any particular atom, but for an average over the
naturally-occurring isotopes, taking their natural abundances into
account. An isotope of a chemical element is defined to be an atom with
the same number of protons (and therefore electrons, if it's not
ionized), and a different number of neutrons -- each possible number of
neutrons in an atom corresponds to a different isotope. Because most
atoms with several stable isotopes have natural abundances that are
shared in some fractional way between the possible isotopes, you will
get fractional masses.
Another very interesting effect is that the mass of an atom
corresponds to the total energy of everything inside. A big piece of
this energy is in fact negative -- it's the potential energy of the
forces which bind the protons and neutrons together. Pull a nucleus
apart into its component protons and neutrons, add up all the masses
you get, and you will have more than if all the protons and neutrons
were stuck together. This is so because you have to add energy to pull
a nucleus apart, and E=mc^2. The binding energy contributes to the
fractional masses of atoms. Furthermore, the electrons and their
kinetic and binding energies also contribute to the total mass of an
atom.
Another effect is that a proton and a neutron have slightly
different masses. The mass of Carbon-12 and Boron-12, for example, will
be different because Boron-12 has one more neutron, and one fewer
proton and one fewer electron. A free neutron will in fact decay into a
proton and an electron and an electron antineutrino, so it has more
mass, and enough to give the electron and neutrino some kinetic energy
in the decay. A neutron bound in a stable nucleus cannot decay in this
manner because the decay of a neutron into a proton changes the binding
energy of the nucleus by more than what you get by turning the neutron
into a less massive proton (minus the minimum energy needed to create
the electron and neutrino).
Tom
(published on 10/22/2007)