The density indicates the mass of the compound per a unit of volume and is computed as the ratio of the mass (m) to volume (V): m/V. The straightforward conversion of the molecular weight (denoted as M) is only possible for gaseous substances, and based on the ideal gas law PV = (m/M)RT; P stands for pressure, T for temperature and R is the molar gas constant. As an example, calculate the density of the carbon dioxide (CO2) gas having the molecular weight of 44 g/mole at the temperature 300 K (Kelvin) and the pressure of 2 atmosphere (atm).

Multiply both sides of the ideal gas equation PV = (m/M) x RT by the value M/RTV to obtain the following expression for the density: Density = m/V= PM / RT.

Round the molar gas constant R to the fourth digit to obtain 8.3145 J/mole x K; this precision is sufficient for most calculations. Note that the constant is given in the International System of Units (SI); J means Joule, a unit of energy.

Multiply the pressure P in atm by the factor 101,325 to convert the pressure to the SI unit Pascal (Pa). In our example, Pressure = 101,325 x 2 atm = 202,650 Pa.

Multiply the pressure and molecular weight, and then divide by temperature T and gas constant to calculate the density (g/cubic meter). In our example, the density of CO2 is 202,650 Pa x 44 g/mole / (8.3145 x 300 K) = 3,574.71 g / cubic meters.

Divide the density in g/ cubic meters by 1,000 to compute it in g/L. In this example, the density = 3,574.71 /1,000 or 3.57 g/L. Note that results in Steps 4 and 5 are rounded to the second decimal point.