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 void _uitoa(unsigned int value, char* string, unsigned char radix)
18 signed char index = 0, i = 0;
20 /* generate the number in reverse order */
22 string[index] = '0' + (value % radix);
23 if (string[index] > '9')
24 string[index] += 'A' - '9' - 1;
29 /* null terminate the string */
30 string[index--] = '\0';
32 /* reverse the order of digits */
35 string[i] = string[index];
42 void _itoa(int value, char* string, unsigned char radix)
44 if (value < 0 && radix == 10) {
48 _uitoa(value, string, radix);