Subversion Repositories Kolibri OS

Rev

Rev 6412 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6412 siemargl 1
#include 
2
#include 
3
#include 
4
#include 
647 andrew_pro 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
*/
6443 siemargl 10
char* itoab(unsigned int n, char* s, int  b)
647 andrew_pro 11
{
12
  char *ptr;
13
  int lowbit;
14
  ptr = s;
15
  b >>= 1;
16
  do {
17
    lowbit = n & 1;
6443 siemargl 18
    n = (n >> 1) & 0x7FFFFFFF;
647 andrew_pro 19
    *ptr = ((n % b) << 1) + lowbit;
20
    if(*ptr < 10) *ptr += '0'; else *ptr += 55;
21
    ++ptr;
22
    } while(n /= b);
23
  *ptr = 0;
6412 siemargl 24
  return strrev(s);
647 andrew_pro 25
}