limit digits properly, to avoid bad digits