The binding of magnesium ions to DNA