2016-04-30 15:50:04 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
2006-11-21 13:36:25 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
** itoab(n,s,b) - Convert "unsigned" n to characters in s using base b.
|
|
|
|
** NOTE: This is a non-standard function.
|
|
|
|
*/
|
2016-06-10 13:10:52 +02:00
|
|
|
char* itoab(unsigned int n, char* s, int b)
|
2006-11-21 13:36:25 +01:00
|
|
|
{
|
|
|
|
char *ptr;
|
|
|
|
int lowbit;
|
|
|
|
ptr = s;
|
|
|
|
b >>= 1;
|
|
|
|
do {
|
|
|
|
lowbit = n & 1;
|
2016-06-10 13:10:52 +02:00
|
|
|
n = (n >> 1) & 0x7FFFFFFF;
|
2006-11-21 13:36:25 +01:00
|
|
|
*ptr = ((n % b) << 1) + lowbit;
|
|
|
|
if(*ptr < 10) *ptr += '0'; else *ptr += 55;
|
|
|
|
++ptr;
|
|
|
|
} while(n /= b);
|
|
|
|
*ptr = 0;
|
2016-04-30 15:50:04 +02:00
|
|
|
return strrev(s);
|
2006-11-21 13:36:25 +01:00
|
|
|
}
|