encode number: if exact, integer, else real