• 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
Re: floats and number formatters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: floats and number formatters


  • Subject: Re: floats and number formatters
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Wed, 14 Jul 2004 16:44:19 -0700

Hello...

You need to set up the number formats in the formatter, which can be done in InterfaceBuilder (the boxes above the maximum and minimum values in the inspector for the formatter) or programmatically using the NSNumberFormatter setFormat: instance method.

To round the number to two decimal places, you would want to use something like 0.00 or 0.## depending whether you want zeros to be displayed for a fixed precision.


For more info, check out the description of the NSNumberFormatter setFormat: instance method
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSNumberFormatter.html#//apple_ref/doc/uid/20000202/CHDCEHHC

and the Cocoa conceptual topic "Data Formatting"
http://developer.apple.com/documentation/Cocoa/Conceptual/DataFormatting/Concepts/NumberFormatters.html#//apple_ref/doc/uid/20000195/BAJBGEJD


Hope that helps,

Louis


I have a field that receives a calculated value. I have a formatter on the field, set to +/-9999.99 (two digit precision).

The calculation returns something like 44.4599999, I **thought** the formatter would round it to two digits (i.e. 44.46) but that's not what I'm getting. I do get displayed 44.4599999.

What am I missing?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >floats and number formatters (From: John Spicer <email@hidden>)

  • Prev by Date: Dumping input to NSTask
  • Next by Date: Re: NSTable Newbie Issues
  • Previous by thread: Re: floats and number formatters
  • Next by thread: NSOpenGLView subclass draw issues in NSPanel
  • Index(es):
    • Date
    • Thread