BSD 4_3_Tahoe release
[unix-history] / usr / src / sys / stand / printn.c
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)printn.c 7.1 (Berkeley) 2/5/88
*/
#include "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);
}