• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSNumberFormatter scientific notation and fraction digits
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSNumberFormatter scientific notation and fraction digits


  • Subject: NSNumberFormatter scientific notation and fraction digits
  • From: "email@hidden" <email@hidden>
  • Date: Sun, 27 Feb 2011 21:42:38 +0000

I have an NSNumberFormatter attached to an NStextField that I switch between decimal and scientific notation like so:
(The use of -setNumberStyle is encouraged in the documents)

[self.formatter setNumberStyle:NSNumberFormatterScientificStyle];
or
[self.formatter setNumberStyle:NSNumberFormatterDecimalStyle];

I then configure decimal places:
[self.formatter setMaximumFractionDigits:3];
[self.formatter setMinimumFractionDigits:3];

When the style is decimal formatting occurs as I would anticipate, so if I enter 1.1234 the value is formatted to 1.123 .
With the scientific style selected I find that an input of 1.1234e0 is formatted as 1.120e0, as is an input of 1.123e0.
ie: the least significant digit is always 0.
This is not what I expect, but my expectations may be off the mark here.

I also tried call -setMaximumSignificantDigits:4 but this did not seem to improve the situation.

Any ideas?

Regards

Jonathan Mitchell

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







_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSNumberFormatter scientific notation and fraction digits
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: iPad widget question
  • Next by Date: Re: NSNumberFormatter scientific notation and fraction digits
  • Previous by thread: Stack+Overflow+Question
  • Next by thread: Re: NSNumberFormatter scientific notation and fraction digits
  • Index(es):
    • Date
    • Thread