Mass is an easy way to measure quantity of matter, but in chemical reactions, it is often important to consider the number of atoms of each element present in a sample. This value is impossible to directly measure, as even the smallest quantity of a substance will contain billions of atoms. It is possible, however, to calculate the number of atoms or molecules in a pure sample so long as the sample's identity and mass are known.

Chemists generally use the mole as the unit for the number of atoms or molecules of a material.
One mole (abbreviated mol) is equal to 6.022 x 10^{23} (Avogadro's number); this is defined as the number of atoms in 12 grams of carbon-12.
One mole of any other element is equal to that element's atomic mass; in the case of molecules, a mole is equal to the sum of its atomic masses.

In the everyday world, different representations are used to express a quantity of a substance.
For example, a dozen eggs is equal to 12 eggs, or 24 ounces of eggs.
Similarly, in chemistry, a quantity can be expressed in different ways; one mole of hydrogen atoms is equal to 6.022 x 10^{23} atoms, or 1.0079 grams of hydrogen.
Knowing the relationship between the atomic weight, molar mass, and moles, we can convert between mass, number of moles and number of atoms very easily.
A compound's or element's molar mass is equal to the atomic weight of the substance multiplied by the molar constant (1g/mol).
This unit is important to ensure consistency in quantitative calculations.

This idea can be illustrated by the following example: How many moles and how many atoms are contained in 10 grams of nickel?
The atomic weight of nickel is 58.69 amu, which means that the molar mass of nickel is 58.69g/mol.
Using dimension analysis we determine that the amount of moles = 10g Ni x 1mol/58.69g = 0.170 mol Ni.
To determine the number of atoms, we employ Avogadro's number: 0.170 mol Ni x 6.022 x 10^{23} atoms/1 mol = 1.02 x 10^{23} atoms Ni.

If a sample's mass and the number of moles thereof are known, its atomic (or molecular, in the case of a non-elemental substance) mass can be confirmed by dividing the mass by the number of moles.