Re: beginner question, NSNumber, NSDecimalAsNumber
Re: beginner question, NSNumber, NSDecimalAsNumber
- Subject: Re: beginner question, NSNumber, NSDecimalAsNumber
- From: Andy Lee <email@hidden>
- Date: Mon, 09 Nov 2009 10:22:58 -0500
On Nov 9, 2009, at 9:55 AM, Jay Swartzfeger wrote:
On Mon, Nov 9, 2009 at 9:52 AM, Alastair Houghton
<email@hidden> wrote:
Anyway, there are lots of neat tricks of this nature.
(All of this probably isn't for newbie C programmers, though it's
perfectly
possible that a newbie ObjC programmer might not be new to C or C++.)
Where I'm still confused, there have been many alternatives offered --
what solution would be used in a Cocoa context?
The answer, as is usual when there are many alternatives, is "It
depends."
Personally, I would skip all the clever solutions. I would start with
an empty NSMutableString and modify Graham's code to prepend "0" or
"1" to the string, thus addressing the "backwards" issue. As a
reminder, here's what Graham posted:
- (NSString *) to_binary( int n )
{
do
putchar(( n & 1 )? '1' : '0');
while( n >>= 1 );
}
Maybe put the NSMutableString code in a category of NSString. I think
this is would be a useful exercise for a Cocoa newcomer.
--Andy
_______________________________________________
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
References: | |
| >beginner question, NSNumber, NSDecimalAsNumber (From: Jay Swartzfeger <email@hidden>) |
| >Re: beginner question, NSNumber, NSDecimalAsNumber (From: Ron Fleckner <email@hidden>) |
| >Re: beginner question, NSNumber, NSDecimalAsNumber (From: Graham Cox <email@hidden>) |
| >Re: beginner question, NSNumber, NSDecimalAsNumber (From: Thomas Wetmore <email@hidden>) |
| >Re: beginner question, NSNumber, NSDecimalAsNumber (From: Alastair Houghton <email@hidden>) |
| >Re: beginner question, NSNumber, NSDecimalAsNumber (From: Graham Cox <email@hidden>) |
| >Re: beginner question, NSNumber, NSDecimalAsNumber (From: Alastair Houghton <email@hidden>) |
| >Re: beginner question, NSNumber, NSDecimalAsNumber (From: Jay Swartzfeger <email@hidden>) |