tags:

views:

490

answers:

3

Hi,

I am extracting double data from sqlite3 database. But I want to display it only upto two decimal places. So how to truncate it.

+2  A: 

Use sprintf formatting with NSString: [NSString stringWithFormat: @"%.2f", myValue];

Ben Gottlieb
+1  A: 

See NSNumberFormatter. It formats numbers.

Terry Wilcox
A: 

Ah, Ben beat me to it! You might also find this http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html useful.