ack/lang/cem/libcc.ansi/stdio/icompute.c

22 lines
387 B
C
Raw Normal View History

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
#include "loc_incl.h"
/* This routine is used in doprnt.c as well as in tmpfile.c and tmpnam.c. */
char *
_i_compute(unsigned long val, int base, char *s, int nrdigits)
{
int c;
c= val % base ;
val /= base ;
if (val || nrdigits > 1)
1989-12-18 15:04:14 +00:00
s = _i_compute(val, base, s, nrdigits - 1);
*s++ = (c>9 ? c-10+'a' : c+'0');
return s;
}