NSNumberFormatter fractional multiplier and -objCType = i

Originator:andrew.d.hershberger
Number:rdar://16775214 Date Originated:4/30/2014
Status:Open Resolved:
Product:iOS SDK Product Version:7.1
Classification:Other Bug Reproducible:Always
 
Summary:
NSNumberFormatter's output is influenced by the Objective-C type of the number passed as input. This behavior was unexpected, and I want to clarify whether this is intentional or a bug.

NSNumber *numberInCents = @9999;

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];

[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setMultiplier:@0.01];

NSString *formattedString = [numberFormatter stringFromNumber:numberInCents];

NSLog(@"formattedString: %@", formattedString);

// formattedString is "$99.00" since the -objCType of numberInCents is i.
// changing numberInCents to @9999.0 results in formattedString equaling "$99.99"

Steps to Reproduce:
1. Create a sample Xcode project
2. Run the sample code from the description
3. Observe the output in the Xcode console

Expected Results:
The expected result is $99.99

Actual Results:
The actual result is "$99.00" since the Objective-C type of numberInCents is i.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!