• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Radix Cocoa Class: Int Binary Value to Char String Using Primitive Operators
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Radix Cocoa Class: Int Binary Value to Char String Using Primitive Operators
      • From: John Stiles <email@hidden>
  • Prev by Date: Re: WebView's mainframe returns nil during WindowDidLoad?
  • Next by Date: Re: Radix Cocoa Class: Int Binary Value to Char String Using Primitive Operators
  • Previous by thread: Re: WebView's mainframe returns nil during WindowDidLoad?
  • Next by thread: Re: Radix Cocoa Class: Int Binary Value to Char String Using Primitive Operators
  • Index(es):
    • Date
    • Thread