To do formatting in objective-c, the result is 120.54.

[sourcecode language=”objc”]
NSLog([NSString stringWithFormat:@"%.2f", 123*0.98]);
[/sourcecode]

It is nearly equivalent to the code in c:

[sourcecode language=”c”]
printf("%.2f", 123*0.98);
[/sourcecode]

Reference

Leave a Reply

%d bloggers like this: