Re: NumberFormatters and sci notation
Re: NumberFormatters and sci notation
- Subject: Re: NumberFormatters and sci notation
- From: Greg Herlihy <email@hidden>
- Date: Thu, 19 Jan 2006 07:57:35 -0800
- Thread-topic: NumberFormatters and sci notation
To specify the precision of the mantissa with a 10.4 number formatter, use
the -setMaximumFractionDigits and -setMinimumFractionDigits methods. In this
case setting both to 4:
[fmt setMaximumFractionDigits:4];
[fmt setMinimumFractionDigits:4];
It is also possible to specify how the last displayed digit should be
rounded with -setRoundingMode.
Greg
On 1/18/06 6:39 AM, "Graham J Lee" <email@hidden> wrote:
> Afternoon all,
>
> I want to set up a NSNumberFormatter attached to a cell to display
> scientific notation with a fixed precision on the mantissa, so that a
> number like 0.00017234784 might be displayed as 1.72e-04. If I
> attach the formatter through IB, then it just specifies strings like
> @"##0,00.00" which format the example above as "0.00". I've tried
> using the numberStyle, thus:
>> [NSNumberFormatter
>> setDefaultFormatterBehavior:NSNumberFormatterBehavior10_4];
>> NSNumberFormatter *fmt=[[[NSNumberFormatter alloc] init]
>> autorelease];
>> [fmt setNumberStyle:NSNumberFormatterScientificStyle];
>> [[c0Field cell] setFormatter:fmt];
> but this formats the number as "1.7234784e-04". How can I restrict
> the mantissa's precision while still retaining scientific notation?
>
> Thanks,
>
> Graham.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden