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