• 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: fastest way to round NSNumber
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fastest way to round NSNumber


  • Subject: Re: fastest way to round NSNumber
  • From: Nathan Day <email@hidden>
  • Date: Sun, 2 Mar 2003 16:11:20 +1030

Trying to round floats and doubles for display is a bad ideas since double and float can only approximate values, for instance you can't represent 0.1 exactly, you are best to treat it as a display issue and handle it at the point of display, you might want to look at the class NSNumberFormatter and it's parent class NSFormatter which are under Foundation kit for some reason instead of Application Kit, I guess you could use them for outputting numbers in a command line app if you wanted to.

On Sunday, March 2, 2003, at 03:41 PM, Nick wrote:

I have a NSNumber with a double value whose NSString representation I want to truncate after the second decimal place... i.e. I have "90.3000000000001" and I want to have "90.30". I can fix it through string manipulation. However, I was wondering if there is a faster method out there to do this?

Nathan Day
http://homepage.mac.com/nathan_day/
_______________________________________________
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: 
 >fastest way to round NSNumber (From: Nick <email@hidden>)

  • Prev by Date: Re: Instantly setting preferences
  • Next by Date: Re: More on releasing NSImages
  • Previous by thread: fastest way to round NSNumber
  • Next by thread: Width of a menu (or menu item)
  • Index(es):
    • Date
    • Thread