/*- * Copyright (c) 1982, 1986 The Regents of the University of California. * All rights reserved. * * %sccs.include.redist.c% * * @(#)printn.c 7.3 (Berkeley) 05/03/91 */ #include "sys/param.h" /* * Printn prints a number n in base b. * We don't use recursion to avoid deep kernel stacks. */ printn(n, b) u_long n; int b; { register char *cp; char prbuf[11]; if (b == 10 && (int)n < 0) { putchar('-'); n = (unsigned)(-(int)n); } cp = prbuf; do { *cp++ = "0123456789abcdef"[n%b]; n /= b; } while (n); do putchar(*--cp); while (cp > prbuf); }