Re: fastest way to round NSNumber
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.