The density of water varies with temperature, thus the grams of water in 1 liter varies. While 1 gram per milliliter is the commonly reported value for the density of water, the actual value is less than this.
Water is most dense at approximately 4 degrees Celsius with a density of 999.97 grams per liter. At 100 degrees Celsius, its density is 958.4 grams per liter. Above this temperature water turns to vapor and becomes even less dense. Ice at -30 degrees Celsius has a density of 983.85 grams per liter. Since ice is not as dense as water, the solid form floats.