Subversion Repositories Kolibri OS

Rev

Rev 6412 | Blame | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5.  
  6. /*
  7. ** itoab(n,s,b) - Convert "unsigned" n to characters in s using base b.
  8. **                NOTE: This is a non-standard function.
  9. */
  10. char* itoab(unsigned int n, char* s, int  b)
  11. {
  12.   char *ptr;
  13.   int lowbit;
  14.   ptr = s;
  15.   b >>= 1;
  16.   do {
  17.     lowbit = n & 1;
  18.     n = (n >> 1) & 0x7FFFFFFF;
  19.     *ptr = ((n % b) << 1) + lowbit;
  20.     if(*ptr < 10) *ptr += '0'; else *ptr += 55;
  21.     ++ptr;
  22.     } while(n /= b);
  23.   *ptr = 0;
  24.   return strrev(s);
  25. }
  26.