The number of grams in a gas describes its mass, but the gas's actual amount is a different quantity. Chemists describe the amount of a gas in terms of the number of particles within it. A fixed amount of gas has a fixed volume, regardless of what gas it is. To find any one particular gas's volume, however, you must also take into account the gas's pressure, which reduces its volume at a fixed amount, and its temperature, which increases the volume at a fixed amount.

Divide the number of grams in the gas by the gas's relative formula mass to calculate the number of moles of molecules in it. If you are calculating the volume of; for instance, 22 g of carbon dioxide, which has a relative formula mass of 44:
22 / 44 = 0.5 moles of atoms.

Divide the gas's temperature by standard temperature, which is 273.15 Kelvin. If the gas has a temperature, for instance, of 300K:
300 / 273.15 = 1.098.

Divide standard pressure, which is 101.3 kilopascals, by the gas's pressure. If the gas has a pressure, for instance, of 160 kPa:
101.3 / 160 = 0.633

Multiply together the answers from the previous 3 steps:
0.5 x 1.098 x 0.633 = 0.348.

Multiply this answer by 22.4, which is the number of liters that a mole of gas takes up at standard temperature and pressure:
0.348 x 22.4 = approximately 7.8. This is the number of liters in the gas.
References
 Photo Credit Jen Siska/Lifesize/Getty Images