Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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