fixed it to work on terminals with over 48 lines, and fixed bug
[unix-history] / .ref-BSD-3 / usr / src / libI77 / fmtlib.c
CommitLineData
914b7558
BJ
1#define MAXINTLENGTH 12
2char *icvt(value,ndigit,sign, base) long value; int *ndigit,*sign;
3register int base;
4{ static char buf[MAXINTLENGTH+1];
5 register int i;
6 if(value>0) *sign=0;
7 else if(value<0)
8 { value = -value;
9 *sign= 1;
10 }
11 else
12 { *sign=0;
13 *ndigit=1;
14 buf[MAXINTLENGTH]='0';
15 return(&buf[MAXINTLENGTH]);
16 }
17 for(i=MAXINTLENGTH-1;value>0;i--)
18 { *(buf+i)=(int)(value%base)+'0';
19 value /= base;
20 }
21 *ndigit=MAXINTLENGTH-1-i;
22 return(&buf[i+1]);
23}