I have an application that needs to display metric units in millimeters and based on the research that I have done (e.g. http://physics.nist.gov/cuu/pdf/sp811.pdf), it is recommended that you don't add grouping separators until you have 5 digits. Is this possible with NSNumberFormatter? I know I could test the value and enable/disable grouping based on its size but I would rather use the appropriate configuration for the NSNumberFormatter if it exists. (BTW, I am on Mac OS X) So for example:
3456 should be shown as 3456 mm
10234 should be shown as 10,234 mm (assuming comma is the grouping separator)
I have read the Apple docs and didn't see anything. I experimented with different searches to find the answer on Stackoverflow but couldn't find a similar question.
Here is how I am currently setting up my NSNumberFormatter:
if (numberFormatter == nil) {
numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setRoundingMode:NSNumberFormatterRoundHalfUp];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
[numberFormatter setLocale:[NSLocale currentLocale]];
[numberFormatter setMinimumFractionDigits:0];
[numberFormatter setMaximumFractionDigits:2];
}
NSNumber *numberInMM = [NSNumber numberWithFloat:fLenInMMs];
NSString *numberStr = [numberFormatter stringFromNumber:numberInMM];
numberStr = [numberStr stringByAppendingString:@" mm"];