Ashutosh
Ashutosh

Reputation: 5742

Formatting a float number inside a Mutable string

I have a couple of floats and they all are stored in a mutable string. But while displaying them it's showing 2011.00000 inspite of 2011 so i want it to format it. Any suggestions.

Thanks

Upvotes: 0

Views: 82

Answers (3)

Max
Max

Reputation: 16719

Use

NSString* sa = [NSString stringWithFormat: @"%0.0f", 22323.4342];

Upvotes: 0

Nyx0uf
Nyx0uf

Reputation: 4649

NSString* str = [NSString stringWithFormat:@"%.f", float_number];

Upvotes: 1

HeikoG
HeikoG

Reputation: 1813

Could you just put them into floats and then use a stringWithFormat(@"%f4.0", ?

Upvotes: 0

Related Questions