Re: beginner question, NSNumber, NSDecimalAsNumber
Re: beginner question, NSNumber, NSDecimalAsNumber
- Subject: Re: beginner question, NSNumber, NSDecimalAsNumber
- From: Graham Cox <email@hidden>
- Date: Mon, 9 Nov 2009 21:27:26 +1100
On 09/11/2009, at 9:01 PM, Ron Fleckner wrote:
void to_binary(int n)
{
int r;
r = n % 2;
if (n >= 2)
to_binary(n / 2);
putchar('0' + r);
return;
}
The above sledgehammer-hammer-ammer-mmer-mer-er is not required to
crack such a nut:
void to_binary( int n )
{
do
putchar(( n & 1 )? '1' : '0');
while( n >>= 1 );
}
--Graham
_______________________________________________
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