add man page, cleandir
[unix-history] / usr / src / sys / stand.att / printn.c
CommitLineData
06a4413c
KB
1/*
2 * Copyright (c) 1982, 1986 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
6 * @(#)printn.c 7.1 (Berkeley) %G%
7 */
8
9#include "param.h"
10
11/*
12 * Printn prints a number n in base b.
13 * We don't use recursion to avoid deep kernel stacks.
14 */
15printn(n, b)
16 u_long n;
17 int b;
18{
19 register char *cp;
20 char prbuf[11];
21
22 if (b == 10 && (int)n < 0) {
23 putchar('-');
24 n = (unsigned)(-(int)n);
25 }
26 cp = prbuf;
27 do {
28 *cp++ = "0123456789abcdef"[n%b];
29 n /= b;
30 } while (n);
31 do
32 putchar(*--cp);
33 while (cp > prbuf);
34}