if i have a value stored like:
long long unsigned x=1000000000000;
i'd like to have a
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
NSNumberFormatter
is the class to go to. For example:
long num = 1000000000;
NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init];
fmt.positiveFormat = @"#,###";
NSLog(@"%@", [fmt stringFromNumber:[NSNumber numberWithLong:num]]);
prints out 1,000,000,000
. There are a lot of predefined styles and further options that can be explored:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With