Is there a possibility to present the same variable in different precisions?
For example, if I’m presenting an addition of two integers, it would be like:
result = 2+3;
NSLog(@"%.0f", result);
but with a division it would be like:
result = 2/3;
NSLog(@"%.1f", result);
Although presenting the π (pi) it would be like:
result = M_PI;
NSLog(@"%.19f", result); //And it would be 3.141592653589793238
NSNumberwill do some quick-and-dirty formatting for you,but you should really use an
NSNumberFormatter:The string format specifiers also allow variable precision; use an asterisk instead of a digit after the decimal point: