sys/libkern/stdio/printf.c
/*
 * Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse
 * order; return an optional length and a pointer to the last character
 * written in the buffer (i.e., the first character of the string).
 * The buffer pointed to by `nbuf' must have length >= MAXNBUF.
 */
Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse
order; return an optional length and a pointer to the last character
written in the buffer .
The buffer pointed to by `nbuf' must have length >= MAXNBUF.
Put a NUL - terminated ASCII number ( base < = 36 ) in a buffer in reverse order ; return an optional length and a pointer to the last character written in the buffer . The buffer pointed to by ` nbuf ' must have length > = MAXNBUF .
static char *
ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
{
	char *p, c;
	p = nbuf;
	*p = '\0';
	do {
		c = hex2ascii(num % base);
		*++p = upper ? toupper(c) : c;
	} while (num /= base);
	if (lenp)
		*lenp = p - nbuf;
	return (p);
}
static char * ksprintn ( char * nbuf , uintmax_t num , int base , int * lenp , int upper ) { char * p , c ; p = nbuf ; * p = ' \0 ' ; do { c = hex2ascii ( num % base ) ; * ++ p = upper ? toupper ( c ) : c ; } while ( num /= base ) ; if ( lenp ) * lenp = p - nbuf ; return ( p ) ; }
Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse
 order; return an optional length and a pointer to the last character
 written in the buffer (i.e., the first character of the string).
Put a NUL - terminated ASCII number ( base < = 36 ) in a buffer in reverse order ; return an optional length and a pointer to the last character written in the buffer ( i . e . the first character of the string ) .