format a value and return the formatted string