chg: generalize number formatting function