formatting value in a string

Member
Posts: 164
Joined: 2010.10
Post: #1
if i have a value stored like:
Code:
long long unsigned x=1000000000000;
i'd like to have a
Code:
NSString *strx=[...];
so if i use NSLog or bitmapfont for this integer, what is displayed will be:
1,000,000,000,000
do exists this king od formatter?
thanks
Quote this message in a reply
Member
Posts: 164
Joined: 2010.10
Post: #2
found it:
long num = 1000000000;
NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init];
fmt.positiveFormat = @"#,###";
NSLog(@"%@", [fmt stringFromNumber:[NSNumber numberWithLong:num]]);
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
You might consider a localized formatter for places where the thousands separator is not a comma.
Quote this message in a reply
Member
Posts: 164
Joined: 2010.10
Post: #4
thanks for suggestion! i'll look for it
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Getting a value from a String Megamac04 5 3,837 Jan 31, 2010 04:23 PM
Last Post: smasher
  Parsing from a string to something faster? Madrayken 3 3,144 Aug 10, 2009 03:32 PM
Last Post: smasher
  Is -fconstant-string-class broken under the XCode/Next runtime Justin Brimm 17 7,713 Jun 12, 2008 01:04 PM
Last Post: Justin Brimm
  string to interger comparison? dareuhl 8 4,415 May 22, 2008 05:44 PM
Last Post: OneSadCookie
  char array versus pointer to string constant question WhatMeWorry 7 7,419 Jan 30, 2007 12:26 PM
Last Post: bronxbomber92