I offer the following as a "Cocoa solution" to the OP's query, whatever that might be taken to mean...

(For extra credit: why must the parameter be unsigned?)

Tom Wetmore

NSString* binaryRepresentation (NSUInteger number)
{
        unichar buffer[64];
        NSUInteger n = 0;
        while (number) {
                buffer[n++] = (number & 1) + '0';
                number >>= 1;
        }
        NSInteger i = 0, j = n - 1;
        while (i < j) {
                unichar temp = buffer[j];
                buffer[j] = buffer[i];
                buffer[i] = temp;
                i++, j--;
        }
        return [NSString stringWithCharacters: buffer length: n];
}
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to