Start with mass and volume
Density = mass ÷ volume. Measure both for the same sample and use compatible units.
Work an example
A sample with mass 54 g and volume 20 cm³ has density 54/20 = 2.7 g/cm³.
Compare like with like
A value in kg/m³ cannot be compared numerically with one in g/cm³ until you convert the units. One g/cm³ is 1,000 kg/m³. Temperature can also affect the density of real materials.