I need to set a label to a number, which may or may not have decimals. I dont want it to be 5.00, just 5 (which may happen when using a standard token). Although, if there are significant decimals, like .56, then it should display 5.56; if it’s .5, then it should display 5.56. Other than by just using a bunch of if-statements, how can I only show the decimals needed (i.e. is there a quick fix or do I need to do this manually)?
Share
In cocoa the best way to format number values for display is with NSNumberFormatter.