1994-10-26 19:15:35 +01:00
|
|
|
/* @(#)fmtlib.c 1.2 */
|
|
|
|
#define MAXINTLENGTH 23
|
1995-09-28 21:49:15 +01:00
|
|
|
|
|
|
|
#include "f2c.h"
|
|
|
|
#ifndef Allow_TYQUAD
|
|
|
|
#undef longint
|
|
|
|
#define longint long
|
|
|
|
#endif
|
|
|
|
|
1994-10-26 19:15:35 +01:00
|
|
|
#ifdef KR_headers
|
1995-09-28 21:49:15 +01:00
|
|
|
char *f__icvt(value,ndigit,sign, base) longint value; int *ndigit,*sign;
|
1994-10-26 19:15:35 +01:00
|
|
|
register int base;
|
|
|
|
#else
|
1995-09-28 21:49:15 +01:00
|
|
|
char *f__icvt(longint value, int *ndigit, int *sign, int base)
|
1994-10-26 19:15:35 +01:00
|
|
|
#endif
|
|
|
|
{ static char buf[MAXINTLENGTH+1];
|
|
|
|
register int i;
|
1995-09-28 21:49:15 +01:00
|
|
|
|
|
|
|
if(value > 0)
|
|
|
|
*sign = 0;
|
|
|
|
else if (value < 0) {
|
|
|
|
value = -value;
|
|
|
|
*sign = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*sign = 0;
|
|
|
|
*ndigit = 1;
|
|
|
|
buf[MAXINTLENGTH-1] = '0';
|
|
|
|
return &buf[MAXINTLENGTH-1];
|
|
|
|
}
|
|
|
|
i = MAXINTLENGTH;
|
|
|
|
do {
|
|
|
|
buf[--i] = (value%base) + '0';
|
1994-10-26 19:15:35 +01:00
|
|
|
value /= base;
|
1995-09-28 21:49:15 +01:00
|
|
|
}
|
|
|
|
while(value > 0);
|
|
|
|
*ndigit = MAXINTLENGTH - i;
|
|
|
|
return &buf[i];
|
1994-10-26 19:15:35 +01:00
|
|
|
}
|