Since they are salts of fatty acids, soaps have the general formula (RCO)M, where R is an alkyl, M is a metal and n is the charge of the cation. The major classification of soaps is determined by the identity of M. When M is Na (sodium) or K (potassium), the soaps are called toilet soaps, used for handwashing. Many metal dications (Mg, Ca, and others) give metallic soap. When M is Li, the result is lithium soap (e.g., lithium stearate), which is used in high-performance greases. A cation from an organic base such as ammonium can be used instead of a metal; ammonium nonanoate is an ammonium-based soap that is used as an herbicide.
When used in hard water, soap does not lather well and a scum of stearate, a common ingredient in soap, forms as an insoluble precipitate.