I am extracting double data from sqlite3 database. But I want to display it only upto two decimal places. So how to truncate it.
Asked
Active
Viewed 5,654 times
3 Answers
7
Use sprintf formatting with NSString: [NSString stringWithFormat: @"%.2f", myValue];

Ben Gottlieb
- 85,404
- 22
- 176
- 172
-
Much simplier than messing around w/ NSNumberFormatter. – DOOManiac Aug 27 '11 at 03:52
0
Ah, Ben beat me to it! You might also find this http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html useful.