1989-12-18 15:04:14 +00:00
|
|
|
/*
|
|
|
|
* icompute.c - compute an integer
|
|
|
|
*/
|
1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1989-12-18 15:04:14 +00:00
|
|
|
|
2018-06-21 20:33:47 +00:00
|
|
|
#include "loc_incl.h"
|
1989-12-18 15:04:14 +00:00
|
|
|
|
2018-06-23 16:54:40 +00:00
|
|
|
#if ACKCONF_WANT_STDIO
|
|
|
|
|
1989-12-18 15:04:14 +00:00
|
|
|
/* This routine is used in doprnt.c as well as in tmpfile.c and tmpnam.c. */
|
|
|
|
|
2018-06-21 20:33:47 +00:00
|
|
|
char* _i_compute(unsigned long val, int base, char* s, int nrdigits)
|
1989-12-18 15:04:14 +00:00
|
|
|
{
|
|
|
|
int c;
|
|
|
|
|
2018-06-21 20:33:47 +00:00
|
|
|
c = val % base;
|
|
|
|
val /= base;
|
1993-08-26 10:08:37 +00:00
|
|
|
if (val || nrdigits > 1)
|
1989-12-18 15:04:14 +00:00
|
|
|
s = _i_compute(val, base, s, nrdigits - 1);
|
2018-06-21 20:33:47 +00:00
|
|
|
*s++ = (c > 9 ? c - 10 + 'a' : c + '0');
|
1989-12-18 15:04:14 +00:00
|
|
|
return s;
|
|
|
|
}
|
2018-06-23 16:54:40 +00:00
|
|
|
|
|
|
|
#endif
|