]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libI77/fmtlib.c
Previous commit was incompleted, yet one step required
[FreeBSD/FreeBSD.git] / lib / libI77 / fmtlib.c
1 /*      @(#)fmtlib.c    1.2     */
2 #define MAXINTLENGTH 23
3 #ifdef KR_headers
4 char *f__icvt(value,ndigit,sign, base) long value; int *ndigit,*sign;
5  register int base;
6 #else
7 char *f__icvt(long value, int *ndigit, int *sign, int base)
8 #endif
9 {       static char buf[MAXINTLENGTH+1];
10         register int i;
11         if(value>0) *sign=0;
12         else if(value<0)
13         {       value = -value;
14                 *sign= 1;
15         }
16         else
17         {       *sign=0;
18                 *ndigit=1;
19                 buf[MAXINTLENGTH]='0';
20                 return(&buf[MAXINTLENGTH]);
21         }
22         for(i=MAXINTLENGTH-1;value>0;i--)
23         {       *(buf+i)=(int)(value%base)+'0';
24                 value /= base;
25         }
26         *ndigit=MAXINTLENGTH-1-i;
27         return(&buf[i+1]);
28 }