Is there a quick way to format numbers (e.g., when using appendFormat) so that only enough decimal places are shown? E.g., 4.23100 is shown as 4.231, while 5.0000 is shown as just 5.
Thanks for reading.
Use %g instead of %f
double n = 1234.5678;
NSString str = [NSString stringWithFormat:@"number is %g", n];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With