|
|
1.1 ! root 1: /* @(#)fmtlib.c 1.2 */ ! 2: #define MAXINTLENGTH 12 ! 3: char *icvt(value,ndigit,sign, base) long value; int *ndigit,*sign; ! 4: register int base; ! 5: { static char buf[MAXINTLENGTH+1]; ! 6: register int i; ! 7: if(value>0) *sign=0; ! 8: else if(value<0) ! 9: { value = -value; ! 10: *sign= 1; ! 11: } ! 12: else ! 13: { *sign=0; ! 14: *ndigit=1; ! 15: buf[MAXINTLENGTH]='0'; ! 16: return(&buf[MAXINTLENGTH]); ! 17: } ! 18: for(i=MAXINTLENGTH-1;value>0;i--) ! 19: { *(buf+i)=(int)(value%base)+'0'; ! 20: value /= base; ! 21: } ! 22: *ndigit=MAXINTLENGTH-1-i; ! 23: return(&buf[i+1]); ! 24: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.