我想传递一个参数来决定小数点后应该有多少值,如下所示
int decimalpoint=2;
NSString *deciPnt=@".2";
NSString *deciPnts=@"2";
CGFloat floatvalue=4.256345;
NSlog(@"Req floatvalue= %%df",decimalpoint,floatvalue);
output should be: Req floatvalue= 4.25
or
NSlog(@"Req floatvalue= %%@f",deciPnt,floatvalue);
output should be: Req floatvalue= 4.25
or
NSlog(@"Req floatvalue= %%@f",deciPnts,floatvalue);
output should be: Req floatvalue= 4.25
我试过这个它对我不起作用..我知道它可以通过NSLog(@"Req floatvalue= %.2f",floatvalue);
请分享你的想法,我希望他们会帮助我......