Radix Cocoa Class: Int Binary Value to Char String Using Primitive Operators
Radix Cocoa Class: Int Binary Value to Char String Using Primitive Operators
- Subject: Radix Cocoa Class: Int Binary Value to Char String Using Primitive Operators
- From: Jordan Evans <email@hidden>
- Date: Fri, 6 Jan 2006 10:36:18 -0800 (PST)
Camillo wrote:
|#define BUF_SIZE 100
|char digits[] = "0123456789ABCDEF"; /* add more
digits if you need a
|radix > 16 */
|char buf[BUF_SIZE];
|char *p = buf + BUF_SIZE;
|
|*--p = 0;
|if (n == 0) *--p = digits[0];
|else while (n) {
| *--p = digits[n % radix];
| n /= radix;
|}
This works great, with a couple of smalls fixes. But,
I didn't want to use anything with mod or division.
Again I'm looking for a way to write this by only
using these operators: shift, is equal, is not equal,
addition, subtraction, and the bitwise operators: & |
^
If no one here knows, I'll probably just put in your
idea so I can move on and think about it later. This
this stuff is interesting to me, I'd really like to
know how the search is done using more primitive operators.
__________________________________________
Yahoo! DSL Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden