remove libcompat_minix as library
[minix3.git] / minix / lib / libminlib / itoa.c
blobac5a84910ee985156d4e457d99459a7e18105657
1 #include <lib.h>
2 /* Integer to ASCII for signed decimal integers. */
4 static int next;
5 static char qbuf[8];
7 char *itoa(int n);
9 char *itoa(int n)
11 register int r, k;
12 int flag = 0;
14 next = 0;
15 if (n < 0) {
16 qbuf[next++] = '-';
17 n = -n;
19 if (n == 0) {
20 qbuf[next++] = '0';
21 } else {
22 k = 10000;
23 while (k > 0) {
24 r = n / k;
25 if (flag || r > 0) {
26 qbuf[next++] = '0' + r;
27 flag = 1;
29 n -= r * k;
30 k = k / 10;
33 qbuf[next] = 0;
34 return(qbuf);