|
|
1.1 root 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.2 (Berkeley) 3/15/90
7: */
8:
9: #include "sys/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: */
15: printn(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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.