Hi Quincey

Thanks for the reply.

On 27 Feb 2011, at 22:07, Quincey Morris wrote:

> On Feb 27, 2011, at 13:42, jonat...@mugginsoft.com wrote:
> 
>> [self.formatter setMaximumFractionDigits:3];
>> [self.formatter setMinimumFractionDigits:3];
> 
> The documentation describes these as affecting "input" to the number 
> formatter, which presumably means strings being interpreted as numbers, and 
> not numbers being formatted as strings.
I would agree.
If you manipulate the NSTextField UI the input is formatted and, if bound, the 
bound value reflects, precisely, the displayed value.
If you manipulate the model value however, the UI displays the formatted value, 
but the underlying model value remains unchanged and may differ from the 
displayed value in terms of precision.

> 
>> I also tried call -setMaximumSignificantDigits:4 but this did not seem to 
>> improve the situation. 
> 
> This one does seem to be for output, not input. Did you also 
> 'setUsesSignificantDigits:YES'? It looks like that's necessary.
> 
That was the problem. The following now functions as per expectations.

NSInteger _decimalPlaces = 3;
[self.formatter setNumberStyle:NSNumberFormatterScientificStyle];
[self.formatter setMaximumFractionDigits:_decimalPlaces];
[self.formatter setMinimumFractionDigits:_decimalPlaces];
[self.formatter setMaximumSignificantDigits:_decimalPlaces+1];
[self.formatter setMinimumSignificantDigits:_decimalPlaces+1];
[self.formatter setUsesSignificantDigits:YES];

The docs are silent on why this is necessary and what the relationship between 
NSNumberFormatterScientificStyle, the fraction digits and the significant 
digits is.

With regard to NSNumberFormatterDecimalStyle setting minimumSignificantDigits = 
2 and inputting 12345 produces an output of 10000 - which is not what I would 
expect.

Can anyone from Apple confirm what the expected behaviour of the significant 
digits methods is?

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.com_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to