1 /*-------------------------------------------------------------------------
2 integer to string conversion
4 Written by: Bela Torok, 1999
8 _uitoa(unsigned int value, char* string, int radix)
9 _itoa(int value, char* string, int radix)
11 value -> Number to be converted
13 radix -> Base of value (e.g.: 2 for binary, 10 for decimal, 16 for hex)
14 ---------------------------------------------------------------------------*/
16 #define NUMBER_OF_DIGITS 16
18 void _uitoa(unsigned int value, char* string, unsigned char radix)
20 unsigned char index, i;
21 /* char buffer[NUMBER_OF_DIGITS]; */ /* space for NUMBER_OF_DIGITS + '\0' */
23 index = NUMBER_OF_DIGITS;
27 string[--index] = '0' + (value % radix);
28 if ( string[index] > '9') string[index] += 'A' - '9' - 1;
33 string[i++] = string[index++];
34 } while ( index < NUMBER_OF_DIGITS );
36 string[i] = 0; /* string terminator */
39 void _itoa(int value, char* string, unsigned char radix)
41 if (value < 0 && radix == 10) {
43 _uitoa(-value, string, radix);
46 _uitoa(value, string, radix);