1 /* $Id: long2str.c,v 1.6 1994/06/24 11:22:36 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
6 /* Integer to String translator
7 -> base is a value from [-16,-2] V [2,16]
8 -> base < 0: see 'val' as unsigned value
9 -> no checks for buffer overflow and illegal parameters
13 #include "ack_string.h"
22 static char numbuf[MAXWIDTH];
23 static char vec[] = "0123456789ABCDEF";
24 register char *p = &numbuf[MAXWIDTH];
25 int sign = (base > 0);
27 *--p = '\0'; /* null-terminate string */
40 if (base < 0) { /* unsigned */
42 if (val < 0L) { /* taken from Amoeba src */
46 for (i = 0; i < 8 * sizeof val; i++) {
60 *--p = vec[(int) (val % base)];
64 *--p = '-'; /* don't forget it !! */
67 *--p = '0'; /* just a simple 0 */